DMax

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

Tina

I've got a control on my subform called System ID that is
connected to the Customer. When I type the Customer into
the main form, all Systems relating to that customer are
brought up in the sub-form. When I select add new record,
I want the next available system ID number to be assigned
to the new record. It was suggested that I use DMax +1.
Is that the best way? What would my code look like?

Thanks for any help that can be offered!
 
Tina,

Your line of code should look something like:

Me.[System ID] = DMax("[System ID]","Systems") +1

assuming both the control on the form and the field in the table are called
System ID (in the same order in the above expression), and the table name is
Systems; substitute as appropriate.

If you are going to a new record through code then put this line right after
the statement that takes you there.

If you are doing this simply by advancing in the form, then use the On
Current event of the form to run this code:



If Forms(ActiveForm).NewRecord = true then

Me.[System ID] = DMax("[System ID]","Systems") +1

End if



HTH,

Nikos
 
Back
Top