Next number for a field

  • Thread starter Thread starter Guy
  • Start date Start date
G

Guy

Can anyone help with a procedure attached to a button on a
form to populate a field with the next number in a
sequence. I can't use autonumber as not ever record will
have this field.

ie: Latest number given to a record is 54, I want the
procedure to populate the field with 55.

Many thanks.
 
***Untested code***
Private Sub CmdButton_Click()
Me.txtSeqNo = DMax("SeqNo", "YourTable") + 1
End Sub
****

If it is a multi-user system, the above may give duplicated number if 2
users do data entry at the same time. In this case you need to use a more
complex process.
 
Back
Top