increment numbers in field without using autonumber

  • Thread starter Thread starter Jula
  • Start date Start date
Use DMax() to get the highest number used so far in that field of the form's
table.

I suggest you do this in the BeforeUpdate event procedure of the form. Since
that's the last possible moment before the record is saved, this reduces the
chance that 2 users are given the same number when entering new records at
the same time.

This kind of thing:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me.ID) Then
Me.ID = Nz(DMax("ID", "Table1"), 0) + 1
End If
End Sub
 
Back
Top