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

Ado Using Seek with Multiple Keys

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
0
0
AU
I am using an access2000 .mdb as my databse in this project
I have an index called codephoto, with 2 keys
Code and Title

rs4.Index = ("codephoto")

' If i use a single key
Look1 = rs.Fields("code")
rs4.Seek Look1, adSeekBeforeEQ

BUT.. If i have 2 keys... this does NOT work !@!@
Look1 = rs.Fields("code") & rs.Fields("Title")
rs4.Seek Look1, adSeekBeforeEQ

??? How do i do a seek with multiple keys.
anf then process as follows.

rs4x = "zzzzzz"
If Not rs4.EOF Then rx4x = rs4.Fields("code") & rs4.Fields("title")


If rs4x <> Look1 Then


Appreciate any help
 
just user pure SQL to do the look up, It will be much faster
 
Or look at the Find method if you absolutely can't do it from your original SQL Statment.
 
The "Seek" method searches the index that you have set looking for a value in that index. If the index has only one field then you are "Seek"ing for only one field. If it has more than one field then your Seek will look for a combination of fields. If you want to Seek on multiple fields then you need an index that includes those fields.

If you want to search on multiple fields without having an index then use the "Filter" method on the recordset.
 
Thanks very much for the replies.
I can now see that i will have to use sql.
Did not realise that seek etc, was weak on multiple fields.

Regards Kennedymr2
 
The following may help.

rs.Index = "codephoto"
rs.Seek "=", codephoto_1, codephoto_2

if rs.NoMatch then
' Not found - do whatever
end if

 
moki-

This particular question was regarding ADO and not DAO as you have provided the syntax for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top