On Wed, 4 May 2005 03:13:03 -0700, "Training Changes" <Training
How can I create consecutively numbered invoices?
Depends. Is this a one-user desktop system, or a networked realtime
database with thirty users creating invoices all at the same time?
If the former, you can do your invoice entry on a Form (tables and
queries don't have any usable events). Put the following VBA code in
the Form's BeforeInsert event (using your own table and fieldname of
course):
Private Sub Form_BeforeInsert(Cancel as Integer)
Me!InvoiceID = NZ(DMax("[InvoiceID]", "[Invoices]")) + 1
End Sub
This will look up the maximum value of InvoiceID in the table
Invoices; return a 0 if there are no records yet; add 1 to the result
and store that value in the textbox named InvoiceID on your form.
John W. Vinson[MVP]