Make single result query appear in a single text box?

tpickles1984

Registered User.
Local time
Today, 09:07
Joined
Feb 5, 2003
Messages
19
I have a query in my database that returns a single value. Is there any way to set up a text box in a form that will simply display this value? So far I've tried creating an unbound text box, and then using expression builder to refer to the query for the control source, which produces this code:

=[QryMaxSerial+1]![Expr1]

This goes into the control source property for the text box, but when I run the form it comes up with the message:

#Name?

Any ideas? Any help would be much appreciated
 
Even though a query returns only a single row and column, it is still a recordset object and you cannot place a recordset object in a control. You can use a function to extract a single row and column from a query though. Try using DLookup().
 
Solved!

Thanks a lot! I used the following code instead:

=DLookUp("Expr1","QryMaxSerial+1")

This did the job nicely. I might be able to tidy it up a bit by doing some of the calculations I need in the Dlookup rather than in a seperate query, but it worked like a charm!

Thanks again
 

Users who are viewing this thread

Back
Top Bottom