Findfirst with multiple fields

  • Thread starter Thread starter john
  • Start date Start date
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
 
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 & "'
 
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.
 
Back
Top