Automatic increment of Invoice number

A

Andreas

How can I make a field inside a form, or better from within the table
directly to read the last Invoice number from the table and assign a default
value an increment of 1 to the last value?
The current field type is text masked with the INV____ prefix but inside the
table only the number is actually stored.
 
A

Andreas

Autonumber will not give me much flexibility, like using input masks or
define the increment starting value.
The second option sounds good but txtNumFld must take the last value from
somewhere, how can I retrieve the last invoice number and assign it there.
Then if my invoice number field is text, will it manage to add 1?
 
R

Rick Brandt

Andreas said:
How can I make a field inside a form, or better from within the table
directly to read the last Invoice number from the table and assign a
default value an increment of 1 to the last value?
The current field type is text masked with the INV____ prefix but
inside the table only the number is actually stored.

In the BeforeUpdate event...

If Me.NewRecord Then
Me!InvoiceNum = Nz(DMax("InvoiceNum", "TableName"),0)+1
End If
 

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