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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test for ADO Find Method

Status
Not open for further replies.

dynamictiger

Technical User
Dec 14, 2001
206
AU
As part of a nested function I am passing criteria to an ADO recordset which is using find to find matching records.

If there is no match ADO kicks me out without an error message.

How do I test my criteria to see if there is a match from within the find method?
 
Check the help files for the NoMatch property.

rst.movefirst
rst.find somevalue

if rst.NoMatch = true then
Didn't find record
else
Did find it
end if

Don't forget the .movefirst if it is in a loop. If you don't set it to the first record, the next time you make a pass the record pointer will be at eof
 
One word of caution:
Code:
NoMatch
will only work for DAO recordsets using the Jet workspace!

Another word of caution: the ADO
Code:
Find
method can't deal with the IS operator

And a final word of caution: It can't deal with multiple conditions using
Code:
And

I had to change my code to use the
Code:
Filter
method instead. Caused me LOADS of frustrations & many dents in my PC ... ;-)

HTH

Cheers
Nikki
 
Yea, my bad. You have to test for EOF using FIND in ADO. I actually knew that, but I just spaced it out. One question: why you would test for BOF? The pointer goes to EOF if the record is not found. Wouldn't BOF be false and EOF true if the table has records and the FIND failed?

I didn't know about the limitations on FIND you mentioned, thanks for letting us know. I hardly ever use it. SEEK seems to be the one that I always end up using, because it is so much faster, but then again, you have to set up indexes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top