Dlookup on multiple criteria (1 Viewer)

Pavczech

Registered User.
Local time
Today, 05:48
Joined
Jul 11, 2012
Messages
41
Hi guys
Could somebody help me to find the error in this syntax, please.

DLookup("[ID]", "Visitors Book - Personal", "[First Name] ='" & Forms![VisitorsBookIn]![First Name] & "'" AND "[Surname] ='" & Forms![VisitorsBookIn]![Surname] & "'" )

It should look for the "ID" of a user "First and Surname" in the "visitors Book - Personal" table

Thanks veru much
 

vbaInet

AWF VIP
Local time
Today, 05:48
Joined
Jan 22, 2010
Messages
26,374
Here you go:
Code:
DLookup("ID", "[Visitors Book - Personal]", "[First Name] = '" & Forms![VisitorsBookIn]![First Name] & "'" AND Surname = '" & Forms![VisitorsBookIn]![Surname] & "'")
 

pr2-eugin

Super Moderator
Local time
Today, 05:48
Joined
Nov 30, 2011
Messages
8,494
Would be helpful if you could tell us where exactly you are getting this error.. For starters..
* Enclose Visitors Book - Personal within [] as [Visitors Book - Personal].
 

Pavczech

Registered User.
Local time
Today, 05:48
Joined
Jul 11, 2012
Messages
41
Hmm not sure I can run:
?DLookup("ID", "[Visitors Book - Personal]", "[First Name] = '" & Forms![VisitorsBookIn]![First Name] & "'")
and
?DLookup("ID", "[Visitors Book - Personal]", "[Surname] = '" & Forms![VisitorsBookIn]![surname] & "'")
separeted but when putted together :
as you said:
?DLookup("ID", "[Visitors Book - Personal]", "[First Name] = '" & Forms![VisitorsBookIn]![First Name] & "'" AND Surname = '" & Forms![VisitorsBookIn]![Surname] & "'"
it comes out with

compile error:
expected: expression

Thanks
 

pr2-eugin

Super Moderator
Local time
Today, 05:48
Joined
Nov 30, 2011
Messages
8,494
Try using this..
Code:
DLookup("[ID]", "[Visitors Book - Personal]", "[First Name] ='" & Forms![VisitorsBookIn]![First Name] & "' AND [Surname] ='" & Forms![VisitorsBookIn]![Surname] & "' ")
 

Users who are viewing this thread

Top Bottom