A family of Microsoft relational database management systems designed for ease of use.
Thank you,
I changed my code to the following, but I do not think the word query is correct
A query refers to a SQL statement that extracts data from a table or combination of tables. VBA code refers to programming code that can automate a task. VBA code can include a query being executed within a code module.
A control contains a single value. A control cannot have a Max value, A Field that a control is bound to can have a Max value. Using the proper terms can help us help you.
Frankly, this is not diffilcult
Me.controlname = Nz(DMax("[fieldname]","tablename"),0)+1
Me.Dirty = False
That is all that is needed. You might need to use criteria in the DMax if you want the max within a group of data. For exmple:
Me.controlname = Nz(DMax("[fieldname]","tablename", "Year(Date() = " & Year(datefield)),0)+1
Will get the max value within the current year.
The Me.Dirty = False commits the current record so that another user doesn't generate the same number.