I have an invoice template with a sequential number. The code below is sitting in Auto_New.
When a new invoice is generated the last invoice number (variable defined as AutoNumber) is picked up from the Template, it is increased by one, and this number becomes the invoice number which is then stored back in the template.
This all works well, but now the client wants me to have the numbering reset at the turn of the calendar year. So the numbering will look like this:
Then as of 1 January 2011 (for example) it will change to 2011 and default back to 01.
Would an expert out there kindly guide me on how I go about doing this.
I know how to have the date_number but I'm unsure of how I go about resetting the number, and the template knows it is back to 01 for the first occasion after the turn of the calendar year. I just can't seem to think of what to do.
'Find the last invoice number created
AutoNumber = AttachedTemplate.CustomDocumentProperties("xInvoiceLast")
'Create a new invoice number
AutoNumber = AutoNumber + 1
'Save this invoice number to the template
AttachedTemplate.CustomDocumentProperties("xInvoiceLast") = AutoNumber
frmInvoice.txtInvoice = Format$(Date, "yyyy") & "_" & Format(AutoNumber, "00")