Avatar of SteveL13
SteveL13
Flag for United States of America asked on

Another DLookup VBA syntax issue

What is wrong with this?

    Me.txtListingsTakenGoal = Nz(DLookup("[ListingsCount]", "tblMemberGoals", "[TeamMember] = " &  Forms!frmSelectDateRangeAndMembers!txtMemberName & " And [GoalMonth] = " &  Forms!frmSelectDateRangeAndMembers!txtMonth And [GoalYear] = " &  Forms!frmSelectDateRangeAndMembers!txtYear)&", 0)
Microsoft Access

Avatar of undefined
Last Comment
SteveL13

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mbizup

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mbizup

And like your other question, if TeamMember is text, use quotes as delimiters.  The above assumes a numeric ID:

    Me.txtListingsTakenGoal = Nz(DLookup("[ListingsCount]", "tblMemberGoals", "[TeamMember] = '" &  Forms!frmSelectDateRangeAndMembers!txtMemberName & "' And [GoalMonth] = " &  Forms!frmSelectDateRangeAndMembers!txtMonth & " And [GoalYear] = " &  Forms!frmSelectDateRangeAndMembers!txtYear), 0) 

Open in new window

SteveL13

ASKER
Is numeric.  But now I have to add yet another criteria.  Please watch for another topic question.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23