Link to home
Create AccountLog in
Avatar of VGuerra67
VGuerra67

asked on

Expected end of statement.

The following code in Access 2016 gives me an "expected end of statement error message".
SQL_PriFam_Qry = "UPDATE ClientInfo " & _
            "SET ClientInfo.PrimaryClientName_C = Nz(DLookUp("ClientID_FK","ProspectiveClients","ProspectID=" & [PrimaryClientName]),0), " & _
            "   ClientInfo.FamilyMember_C = Nz(DLookup("ClientID_FK", "ProspectiveClients", "ProspectID=" & [FamilyMember]), 0) " & _
            "WHERE (((ClientInfo.ClientID)=1494))"
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
When you build SQL in VBA (which I rarely do since I prefer working with querydefs), you should always print it to the debug window to see what your actual string looks like.  This will show you any syntax errors.  If after you print the string, you still don't see the error, copy the string and paste it into the QBE in SQL View and see what Access has to say.  Frequently you'll get a better error message.

Put a stop on the line that executes the query.  When the code stops, print SQL_PriFam_Qry to the window.
Avatar of VGuerra67
VGuerra67

ASKER

Thanks that works