How to generate auto increment invoice number

A

AccessNovice

Is it possible to generate auto increment invoice number where we
already have existing records. If it is possible, how?

Also, this database will be hosted on a website and accessed by 2 or
more users - at times simultaneously.

Please explain step-by-step as I am very new to Access.


Thank you, thank you, thank you in advance.
 
A

Arvin Meyer [MVP]

You can look at the existing table, find the highest value using the DMax()
function, then add 1 to it and immediately save the record so that you are
less likely to conflict with another user.

The code for a new record is simple (aircode):

Sub Form_Current()
If Me.NewRecord = True Then
Me.txtIDField = DMax("IDField", "TableName")
End If
End Sub
 
A

AccessNovice

Thank you so much, Arvin.

I put Me.txtIDField = DMax("IDField", "TableName") + 1
 

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