Next number for a field

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.
 
V

Van T. Dinh

***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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top