I see this advice, from time to time...and believe I even saw it in a hack by Allen Browne years ago...but in today's VBA it's inappropriate for this task.in a multi user environment better to use the form before update event or perhaps the before insert event...
what is wrong with using invoiceID?
if you want a separate invoice number field, then create a 'invoicenumber' field and use the dmax function to find the latest number - then add 1
here is a link to the dmax function
https://support.office.com/en-ie/article/dmin-dmax-functions-f5c6de87-8752-4f29-ab4b-c554053d299f
in the db you provided your invoice table has an ID field (autonumber), it does not have an invoice number field.I already separate invoice table and field
in the db you provided your invoice table has an ID field (autonumber), it does not have an invoice number field.
Autonumber fields are not editable - so you need another field for your invoice number
autonumbers do generally increment, but you will get gaps if you start to create an invoice and then don't save it.
If your accounting function cannot live with gaps in the number sequence then as advised, you need another field and use the dmax+1 method to populate it
Can't make him do the backstroke, either...no matter how hard you try! :banghead:You can lead a horse to water, but you cannot make him drink!
I don't know why this has persisted, even among knowledgeable people such as yourself, but it has. As I said, I'm pretty sure I've even seen it in some of Allen Browne's hacks. I really have to wonder if it performed differently in the early versions of Access. I've always ignored it when seeing it previously, but decided to test it this time. I was really surprised to see that it even fired before the OnDirty event.I stand corrected - thanks for pointing it out
Business questions;how to create sequential numbering invoice in access form ???
Me.InvoiceNumber = nz(DMax("[InvoiceNumber]","Invoice Table"),0) + 1