Increment an invoice number

kkershaw

Registered User.
Local time
Today, 17:44
Joined
Apr 11, 2002
Messages
17
Hello everyone. I love this discussion forum!
My question is: I want my form to increment an invoice number if I have a checkbox checked. Otherwise I want the invoice number to stay the same as the previous form entry. How can I accomplish this?

Thank you in advance!
 
Hi

This bit of code will add one to the current invoice number when the check box (chkUpdateInvoiceNo) is true and subtract one when the box is unchecked (in case it was checked by mistake).

Private Sub chkUpdateInvoiceNo_Click()

me.txtInvoiceNo = me.txtInvoiceNo + iif(chkUpdateInvoiceNo, 1, -1)

end sub


You'll also need to bring in the last used invoice number to every new record. Try

Private Sub Form_BeforeInsert (Cancel as integer)

me.txtInvoiceNo = DMax("[MyField]","MyTable")

End Sub

where invoice numbers are stored in MyField in table MyTable.

NB BeforeInsert event occurs when you type the first character in the new record.


- hth -

shay :cool:
 

Users who are viewing this thread

Back
Top Bottom