DLookup in report text box

Trying to get a report to use dlookup based on a value on a form (fReportSelect) in the drop down field of LocSelect.

In my report I have the following in a text box:

=DLookUp("Abr","tOffice","Office = " & "'" & ([Forms]![FReportSelect]![LocSelect]) & "'")


But it's not pulling up values from table tOffice.

What is wrong with my syntax?
thandelAsked:
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.

PatHartmanCommented:
What is the value of ([Forms]![FReportSelect]![LocSelect]) ?
Does it exist as a value of Office in tOffice?
Is the confusion caused because of a table level lookup?
0
thandelAuthor Commented:
It's a text value and yes its matches up with the values in the table (the drop down list gets the value from the table I'm dlooking up with.
0
PatHartmanCommented:
Is the other report open?  The implication of your syntax is that some form or report is referencing a different form or report.  Otherwise, the syntax would be:
 
=DLookUp("Abr","tOffice","Office = " & """ & LocSelect & "'")

You might also be missing quotes:

=DLookUp("Abr","tOffice","Office = " & """" & LocSelect & ""'")
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

thandelAuthor Commented:
It's a form and yes the form is open.... I tried both your suggestions but I get an error "The expression you entered has an invalid string"
0
bfuchsCommented:
try this

=DLookUp("Abr","tOffice","Office = " & "'" & ([Forms]![FReportSelect].[LocSelect]) & "'")

Open in new window

or
=DLookUp("Abr","tOffice","Office = " & "'" & [Forms]![FReportSelect].[LocSelect] & "'")

Open in new window

0
thandelAuthor Commented:
Odd no errors but nothing is displaying.    If I use just [Forms]![FReportSelect].[LocSelect] it works OK to display the value from the drop down list on the form.
0
bfuchsCommented:
are you sure there are none null values on the table?
what happens when you try the actual value in debug window?
0
thandelAuthor Commented:
nope no null values.  Not sure how to the value in the debug in window - sorry
0
bfuchsCommented:
?DLookUp("Abr","tOffice","Office = " & "'" & PutTheValueOnFormHere & "'")
and press enter
0
thandelAuthor Commented:
Where do I type that in to?
0
thandelAuthor Commented:
I think in the Immediate window?

I did that and go the following error:

"Compile error, expected: list separator or )"
0
bfuchsCommented:
in code look for the immediate window.
or you can also type that in any query
0
bfuchsCommented:
what did you you type, post the value
0
thandelAuthor Commented:
?DLookUp("Abr","tOffice","Office = " & "'" & Central Square & "'")
0
thandelAuthor Commented:
IF I do this ?[Forms]![FReportSelect]![LocSelect] I get the correct value on the form
0
thandelAuthor Commented:
Seems to be some sort of issue with dlookup
0
bfuchsCommented:
try this
?DLookUp("Abr","tOffice","Office = '" & "Central Square" & "'")

Open in new window

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
thandelAuthor Commented:
That worked
0
thandelAuthor Commented:
so ?DLookUp("Abr","tOffice","Office = '" & [Forms]![FReportSelect]![LocSelect] & "'") works!
0
thandelAuthor Commented:
Got it now and I learned about the debug window! Thanks!
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.