473,320 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Looking for data in an ADO recordset

I am tyring to write something in VB that lets me check if the first and last record in the OwnName field are identical.

I am also trying to find out if the field SubParcelNo has a 2 in it. This field may also have entries like 2A, 2C I don't want to know about them, only if it has just a 2.

Is this possible?

My attempts at it have failed.
Jun 14 '07 #1
4 1363
MMcCarthy
14,534 Expert Mod 8TB
I am tyring to write something in VB that lets me check if the first and last record in the OwnName field are identical.
Your problem here is identifying the first and last record. You can open a recordset and order it based on primary key field assuming it is an autonumber. Then get the value of the field in the first record and pass it to a variable then go to the last record and compare the variable to the value of the field.

I am also trying to find out if the field SubParcelNo has a 2 in it. This field may also have entries like 2A, 2C I don't want to know about them, only if it has just a 2.
What is the makeup of the field SubParcelNo. Is it a text field? Do you just want to create a query to return all records where SubParcelNo is 2

WHERE SubParcelNo LIKE '2'
Jun 16 '07 #2
ADezii
8,834 Expert 8TB
I am tyring to write something in VB that lets me check if the first and last record in the OwnName field are identical.

I am also trying to find out if the field SubParcelNo has a 2 in it. This field may also have entries like 2A, 2C I don't want to know about them, only if it has just a 2.

Is this possible?

My attempts at it have failed.
This will point you in the right direction. The following code will check to see if the Last Names are identical for the First and Last Records of a Recordset based on qryEmployee. Hope this helps.
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
  2. Dim strFirstValue As String, strLastValue As String
  3.  
  4. Set MyDB = CurrentDb()
  5. Set MyRS = MyDB.OpenRecordset("qryEmployee", dbOpenSnapshot)
  6.  
  7. MyRS.MoveFirst
  8.  strFirstValue = MyRS![LastName]
  9.  
  10. MyRS.MoveLast
  11.   strLastValue = MyRS![LastName]
  12.  
  13. 'case insensitive match on Last Name
  14. If UCase$(strFirstValue) = UCase$(strLastValue) Then
  15.   MsgBox "Last Names are a match!"
  16. Else
  17.   MsgBox "No Match on Last Name for First and Last Records!"
  18. End If
  19.  
  20. MyRS.Close
Jun 16 '07 #3
Okay that works great, I forgot to mention the datatype is text and it is already sorted so I just wrote this:

Expand|Select|Wrap|Line Numbers
  1. 'Check if there are more than one owner
  2.     conveyQueryData.MoveFirst
  3.     FirstOwner = conveyQueryData("OwnName").Value
  4.     conveyQueryData.MoveLast
  5.     LastOwner = conveyQueryData("OwnName").Value
  6.     conveyQueryData.MoveFirst
  7.  
After I got this working I got thinking that if I just extended this a bit it would be even better. It would be most useful to know that Smith was owner 1 and Jones was owner 2 etc. I was thinking an array would work and I could just loop throught he recordset and check if the owner is different and if it is add it to the array, then I could use the array index and size to determine if there are more than one owner and if they are the first, second or third owner. I get confused when working with arrays so I guess I just want to ask if this seems like it would work, or will I finish slogging through it and only dicover my own stupidity.
Jun 18 '07 #4
I thought the following thread and this one were different, but thinking about it, they are really two ways of looking at the same problem. Perhaps merging them would be good. I think this violates one of the posting guidlines, sorry if it does. I did not intend to make two posts on the same thing.

showthread.php?p=2640647#post2640647

I really don't know, maybe using code is better than using a query, I am too new at this to have any kind of opinion. Thank you
Jun 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bill | last post by:
I currently connect to two servers. One is IIS, that runs my asp and sql server, and the other is an AS400, that also cranks out data. Sometimes I have to wait for data I submit to the as400 to...
1
by: Jeff Uchtman | last post by:
Query in ASP against a MS SQL DB. <% Dim Sql Dim Conn Dim totalCount Dim rsCount Dim rsACount Dim PetACount Dim rsBCount
5
by: Abby Lee | last post by:
My code does what I want (works unless there is a lot of volume...works for this month cause not a lot of items marked paid yet...) but the page times out for last month because there is just so...
4
by: Agoston Bejo | last post by:
I would like to use an ADODB.RecordSet object to temporarily store some data and then iterate through it. Actually it needs to be a RecordSet only because it is a perfect choice as data structure...
0
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a...
0
by: Channing Jones | last post by:
Hello everyone, I am trying to store data in a binary field of an SQL-Server table using ADODB. So far, I have managed to store a record but not any data in the binary field. I only get...
2
by: Josh Strickland | last post by:
I am attempting to create an Access database which uses forms to enter data. The issue I am having is returning the query results from the Stored Procedure back in to the Access Form. ...
2
by: David C. Barber | last post by:
upsized an MDB to ADP/SQL Server 2000 under Access 2000. All the DAO code that I've changed to ADO code is working fine, HOWEVER the form Record Source itself does not seem willing to return data....
1
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am...
7
by: Joe-Paul Robb, Jr. | last post by:
Hello: I am building a program in Visual Basic 6.0. (Op Sys: Windows XP 2002 Service Pack 2) I placed an AOD Data Control on a form...and a data Grid. I bound the data grid to the data...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.