C
CW
I have an invoice form that when opened, uses the following code to allocate
the next invoice number (InvNo):
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.InvNo = Nz(DMax("[InvNo]", "[tblInvoices]")) + 1
Me.Dirty = False
End Sub
Trouble is, if I then decide for some reason not to carry on, even if I
click on the Close button rightaway without having entered anything anywhere,
the invoice number is still used and appears in the Invoices table (without
any values in any of the fields, of course).
How can I prevent this? Ideally I would like to be able to cancel at any
point before hitting the Save button, even if I have populated a few
controls, and the InvNo would not be used.
Looking forward to your help, thanks
CW
the next invoice number (InvNo):
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.InvNo = Nz(DMax("[InvNo]", "[tblInvoices]")) + 1
Me.Dirty = False
End Sub
Trouble is, if I then decide for some reason not to carry on, even if I
click on the Close button rightaway without having entered anything anywhere,
the invoice number is still used and appears in the Invoices table (without
any values in any of the fields, of course).
How can I prevent this? Ideally I would like to be able to cancel at any
point before hitting the Save button, even if I have populated a few
controls, and the InvNo would not be used.
Looking forward to your help, thanks
CW