Using query as controlsource for textbox

rpadams

Registered User.
Local time
Today, 11:00
Joined
Jun 17, 2001
Messages
111
I have a database that essentially is a complete check printer and check register. I have a query (qryLastCheck) that returns the variable LastCheckNumPrinted which I would like to use as the starting point for automatically adding +1 for a new check. I also want to see this as a value on my input form. What is the correct syntax for the control source to see this value in a textbox? I have tried the following with no luck:

=qryLastCheck!LastCheckNumPrinted

=me!qryLastCheckNumPrinted.value

Both return #Name (error)

I could make this an unbound subform, but it seems like a lot of work essentially when I want to use the value as well.

Final question: Is than an easier way to do this, perhaps with a whole different approach?
 
rp,

You can do this:

=DMax("[LastCheckNumPrinted]","qryLastCheck")

Or eliminate the middle man and just reference the table.

Wayne
 
Works great, but....

Using the Dmax function in the control source was just what I needed and I added a criteria that let me select one of three accounts this database tracks. I'll be using this technique over and over again!

Thank you. It let me erase the query (which had the DMax function) and made the whole thing a lot cleaner.

But... I still would like to know how to reference a query result as the control source for a textbox. I can think of many much more complex queries where I could use this.
 
You could also create a Function which opens the recordset and get the last number, the function is then used to set the DefaultValue of the Cheque number
 

Users who are viewing this thread

Back
Top Bottom