Findfirst with multiple fields

J

john

I'm using the cod below to search for the first last name
entered. For cases with multiple occurrences of a last
name, I'd like to be able to do a secondary search on the
first name field to get to the correct record. Any
suggestions?


strCriteria = "Lname = '" & Me.ctlLName & "'"

rst.FindFirst strCriteria
 
M

Marshall Barton

john said:
I'm using the cod below to search for the first last name
entered. For cases with multiple occurrences of a last
name, I'd like to be able to do a secondary search on the
first name field to get to the correct record. Any
suggestions?


strCriteria = "Lname = '" & Me.ctlLName & "'"

rst.FindFirst strCriteria


You can specify multiple criteria by combining them with And
or Or. I think you want:

strCriteria = "Lname = '" & Me.ctlLName & "' And FName = '"
& Me.ctlFName & "'
 
J

John Vinson

I'm using the cod below to search for the first last name
entered. For cases with multiple occurrences of a last
name, I'd like to be able to do a secondary search on the
first name field to get to the correct record. Any
suggestions?


strCriteria = "Lname = '" & Me.ctlLName & "'"

rst.FindFirst strCriteria

strCriteria can be an almost arbitrarily complex expression,
evaluating to a legal SQL WHERE clause (without the word WHERE). For
instance, you could easily change this to

strCriteria = "[LName] = " & Chr(34) & Me!ctlLName & Chr(34) _
& " AND [FName] = " & Chr(34) & Me!ctlFName & Chr(34)

Note the use of Chr(34) - a doublequote character " - to delimit the
name rather than your singlequote ', which will fail on names like
O'Toole or d'Artegny.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top