DMax + 1

  • Thread starter Thread starter Tina
  • Start date Start date
T

Tina

I have a form and a subform. The form brings up the
Customer and then the subform brings up all records
pertaining to that customer. When I click the add button,
I want the next available record Id Number to be displayed
in the new record. It was suggested that I use DMax +1,
but I'm confused on what the code would look like and
where I should place it. Any help that can be given would
be greatly appreciated. Thanks!!
 
On my website(see sig below) is a small sample database called
"FormSubform.mdb" which illustrates this. Look at the code behind the
Subform.
 
In the DefaultValue of the control try:

=DMax("[FieldName]", "TableName")+1

This should work as long as you only have one user writing new records to
the database. If you have more than one, you will have to "block" the number
from other users.
 
Back
Top