Dlookup two criteria

ikzouhetnietweten

Registered User.
Local time
Today, 11:20
Joined
Oct 23, 2015
Messages
44
I want my textbox FirstName to work.
So I have a Dlookup that has to search for two criteria.
I need to lookup the FirstName field in the table Klanten.
It just stays empty in my form after I click a Customer and contactperson in the comboboxes.
txtnaam contains the customername that it has to lookup aswell in the table Klanten.

Code:
Private Sub Contactpersoon_AfterUpdate()
Me.FirstName = DLookup("FirstName", "Klanten", "[LastName]= '" & Me.Contactpersoon & " AND [Klantnaam]= " & Me.txtnaam & "'")
End Sub
 
Last edited:
Code:
Private Sub Contactpersoon_AfterUpdate()
Me.FirstName = DLookup("FirstName", "Klanten", "[LastName]= '" & Me.Contactpersoon & "[COLOR=red][B]' [/B][/COLOR]AND [Klantnaam]= [COLOR=red][B]'[/B][/COLOR]" & Me.txtnaam & "'")
End Sub
I think there were two single quotes missing. One before "AND [Klantnaam] and one after (in red above).
 
Glad to hear it helped. Did much the same thing myself not long ago.
 

Users who are viewing this thread

Back
Top Bottom