Dmax

lipin

Registered User.
Local time
Today, 20:51
Joined
May 21, 2002
Messages
149
I am trying to populate a textbox on a form with the max value in a field of a table. I am setting default value of txtbox to:
=DMax([tablename]![fieldname])

and its not working. Is this even possible or wishful thinking?

I am trying to pull in the max value, add 1 to it when I Click a command button that prints the report, and then on the report reference the max + 1 value. This is so that whenever I print the report a new invoice number will come up.

But need to get the max value from the table onto the form first.
 
Thanks Rich. That got the max.

It leads me to another problem. Is it possible to have all the controls on the form bound to the table, except 1 and have it bound to a table with only 1 field? So that when the report is printed, this Max value that I pull in and then add 1 to, will be saved. So the next time I print report the value will be the new Max.

I set the control source for textbox to: =[tablename]![field]
in the print command button GotFocus event I have:

txtRef.Value = DMax("[Count]", "PrintCount") + 1

and when I put focus there I get error:
can't assign a value to this object

but when I don't enter a control source in txtRef everything is fine, but then I can't store the new value.
 
I prefer to add the invoice number at the time of the invoice creation and not when the invoice is printed, assuming you don't want to do it that way, use an append query to add the number to the table before printing.
 

Users who are viewing this thread

Back
Top Bottom