Syntax issue in DLookup

SteveL13
SteveL13 used Ask the Experts™
on
I'm getting a syntax error with:

= DLookup("[QtyTransferred]", "query3", "[OwnerName] = 'John Doe ABC' & " AND [Crop] = '" & [Reports]![rptInventoryOwnership]![txtCrop2] & "'")

NOTE:  An expert helped me with a very similar issue a couple of days ago.  I hope someone can figure this one out for me.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Owner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
= DLookup("[QtyTransferred]", "query3", "[OwnerName] = 'John Doe ABC' AND [Crop] = '" & [Reports]![rptInventoryOwnership]![txtCrop2] & "'")
The & sign is used to "piece" together your string. "demo" & "2" results in "demo2". Now the final expression has to be readable by the query engine. If in doubt, place a breakpoint on the line of code, copy the part from the 3rd parameter/argument of the dlookup, directly into the immediate window, and place a ? in front of it and hit enter. The result should illustrate what the "final" string will look like.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial