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

how to find a recordset with ADO

Status
Not open for further replies.

ythg

Programmer
Dec 13, 2002
4
ID
How can i find a recordset with ADO. i already know how to declare the ADO. but when i want to go to the record i want. i have trouble because i need to find a record which have 2 condition to complete.

example like this :

with rst
.find kode = !skode and nk = !nkode

how to declare it so, it can works ..

Thanks
 
If kode and nk are numbers:
with rst
.findFirst "kode = " & !skode & " and nk = " & !nkode

If they are text type:
.findFirst "kode = '" & !skode & "' and nk = '" & !nkode & "'"

If they are date type:
.findFirst "kode = #" & Format(!skode,"mm/dd/yyyy") & "# and nk = #" & Format(!nkode,"mm/dd/yyyy") & "#"

Good luck
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
sorry, should be like this

.find "[fieldname]='" & strValueToFind & " AND " [fieldName2] = '" & strValueToFind & "'"

.seek would be faster but relies on indexing and is a bit more complex website:
 
MadJock: Seek is awful nowadays. Mainly because it only works with native tables. If you base your code on Seek method and then you split the database, you'll be in trouble...

Regards,
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
In ADO the filter method is the most efficient and easy to use.

rst.Filter = "kode = 'a literal' and nk = " & anumber
' do you processing
'- turn off filter before refiltering.
rst.Filter = adFilterNone
rst.Filter = "kode = 'something else'"

If you have a large ADO recordset, you can add an in memory index before filtering.
rst.("kode").Properties("OPTIMIZE") = True
 
Thanks for everyone to help me. but from all your suggestion to use seek. but i don't know how to use seek property.

Or can i use bookmark property? .. if i could, i don't know how to use it.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top