Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB Find operator 1

Status
Not open for further replies.

Orion45

IS-IT--Management
Feb 6, 2002
155
US
I have a module which creates an ADODB recordset from a small SQL statement. I then need to find a specific record within the recordset. I started using the find operator of the recordset to do this and it worked.
Code:
rsGetReading1.Find ("sys_Requirement_ID = " & intReqID & "")
The problem is, for this to work correctly I need to search with two criteria (PersonID and RequirementID). I can't seem to find the syntax for using more than one criteria. Does anyone know how to do this or perhaps a better way of performing a search on a recordset? Any help is appreciated. Thanks
 
Maybe you could modify your SQL statement so it includes criteria for only returning rows where the two fields match.
Alternatively, the Find just does a sequential search through the recordset, so if, for some reason, you can't limit the recordsed to just the records in question, there would be no reason not to write a Do While loop to look at all of the rows, and do whatever when you come to a matching row:

rsGetReading1.movefirst

Do While Not rsGetReading1.EOF
if rsGetReading1.Fields(&quot;<field1_name>&quot; = <whatever> and rsGetReading1.Fields(&quot;<field2_name>&quot;) = <whatever2> then
<do something>
Exit Do
End If
rs.MoveNext
Loop

Good Luck,
Tranman
 
Use the filter method. You can have multiple criteria and it will not reread the data from the source.

rs.filter = &quot;sys_Requirement_ID = &quot; & intReqID etc......

Remove the filter by.
rs.filter = adFilterNone
 
The .filter operator worked great, Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top