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

DLookup for 2 fields

Status
Not open for further replies.

kgerlitz

Technical User
Oct 2, 2004
84
0
0
US
I have this code that does what I want it to do. However, I want to take it a step further and have it search within the "AFLastName" field for a match as well. How can I modify this code to search both the "AMLastName" and "AFLastName" fields?

Private Sub AMLastName_Exit(Cancel As Integer)
If DLookup("AMLastName", "DatabaseAdoptiveParent", "AMLastName='" & AMLastName.Value & "'") = Me.AMLastName.Value Then
Duplicate.RowSource = "SELECT APIDName FROM DatabaseAdoptiveParent WHERE AMLastName='" & Me!AMLastName & "'"
End If
End Sub
 
Something like this ?
If DLookup("AMLastName", "DatabaseAdoptiveParent", "AMLastName='" & AMLastName.Value _
& "' AND AFLastName='" & AFLastName.Value & "'") = Me.AMLastName.Value Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top