Access 2016 DLookUp systax

I have table tbl_Master Contacts Mailable with contact fields including Zip5 (zip codes).

I have table tbl_Counties Zip Codes with Zip Codes and Counties.

I need to use Access 2016 DLoopUP to add the counties from tbl_counties Zip Codes to the matching Zip5 in tbl_Master Contacts Mailable.

I get the following error: The expression entered contains invalid syntax. You may have entered an operand without an operator.”

find_county:DLookUp (“[County]”,”tbl_Counties Zip Codes”,”[Zip Code]='"&[Zip5]""')

What is the proper coding?
Larry FisackerlyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
Rather than using a dLookup, why not simply create a query that looks something like:

SELECT MC.*, ZC.County
FROM tbl_Master_Contacts as MC
LEFT JOIN tbl_Zip_Codes as ZC on MC.Zip5 = ZC.Zip5

DLOOKUP is generally time consuming and not nearly as efficient as using a query.

but if you insist on using the DLOOKUP:

find_county:DLookUp (“[County]”,”tbl_Counties Zip Codes”,”[Zip Code]='" & [Zip5] & "'")

I assume this is in a query, not as the control source of a control on a form.  You might consider putting this DLOOKUP in the Control Source of a control on a form if you are using it in a form.  That way, you would not have to compute it for every record in the recordset, only those records which you actually land on.
0
Larry FisackerlyAuthor Commented:
I pasted the DLoopUP code you sent back. I got the same error. What now?
0
Gustav BrockCIOCommented:
Try using brackets and true double quotes (no pasting):

find_county: DLookUp ("[County]","[tbl_Counties Zip Codes]","[Zip Code] = '" & [Zip5] & ""')

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

Larry FisackerlyAuthor Commented:
That worked. Thanks.
0
Dale FyeOwner, Developing Solutions LLCCommented:
Larry,

Don't forget to close out the question.
0
Gustav BrockCIOCommented:
Question is answered.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.