Incremental values in Orders form

  • Thread starter Thread starter Syphonics via AccessMonster.com
  • Start date Start date
S

Syphonics via AccessMonster.com

I had a Orders form for me to key in the data for the particular orders into
my order table.
I had a field call the "InvoiceID".
The order form allows me to key in the InvoiceID. Now i want to have a button
to allows me to increase the values in the InvoiceID by 1.
But each time i go for a new order, it is a new record, all the values in the
order form is "null". How do i retrieve the InvoiceID value from the previous
record.
 
Use the BeforeInsert event procedure of the form to look up the highest
number used so far, and add 1.

The code will be something like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.InvoiceID = Nz(DMax("InvoiceID", "Orders"),0) + 1
End Sub
 

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

Back
Top