dlookup error 2001

G

Guest

Hello,

I have a query, LocationQuery2:

SELECT Count(GeneralTable.LocDesc) AS totalRatings, LocationQuery.LocDesc
FROM LocationQuery
GROUP BY LocationQuery.LocDesc;

Which takes LocDesc from the parameter query, LocationQuery:

SELECT GeneralTable.LocDesc, RatingsTable.Rating
FROM GeneralTable LEFT JOIN RatingsTable ON GeneralTable.Rating2 =
RatingsTable.Rating
WHERE (((GeneralTable.LocDesc) Like [Enter the Location Desc]) AND
((RatingsTable.Sorting)<>1));


I am trying to use a Dlookup to print the value from LocDesc in
LocationQuery2 into a text box in a report, but I keep getting "Run-time
error '2001': You cancelled the previous operation".

Essentially, when I run LocationQuery2, I enter in a parameter, "Brazil",
and one row is printed, "47" for totalRatings and "Brazil" for LocDesc. My
Dlookup in my report text box is: =DLookUp("[LocDesc]", "[LocationQuery2]").
Why can't I just get it to display "Brazil"?

Please Help!!
 
K

Ken Snell \(MVP\)

You cannot use DLookup when the source query asks the user for a parameter
because DLookup will not cause the query to prompt for that value. You'll
need to change the query to read the desired value from a textbox on a form
that is open when the DLookup function is being run.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DLookup can't find a value 13
DLookup in a grouped footer 4
Access Can't Get Dlookup To Work 1
Dlookup Help 5
DLookup stops working in SubReport - why? 0
Dlookup issue 3
DlookUp Syntax problem 12
Dlookup in Detail 7

Top