I need help tweaking the following code to reset the incremental numbering part of my invoice number. It works wonderfully; however, due to the high number of invoices created, it needs to be reset daily.
The invoice format is yyyymmdd-0000, the last four digits are the incremented numbers from the code below. Currently, the invoice numbers are 20111221-0001, 20111221-0002, 20111222-0003, 20111223-0004. I want the last four digits to restart at 0001 each day, then increment until the next day.
The date part is also stored in the same table as InvDate.
Thanks in advance! I don't know what I would do without this forum!
The invoice format is yyyymmdd-0000, the last four digits are the incremented numbers from the code below. Currently, the invoice numbers are 20111221-0001, 20111221-0002, 20111222-0003, 20111223-0004. I want the last four digits to restart at 0001 each day, then increment until the next day.
The date part is also stored in the same table as InvDate.
Code:
Public Function MakeNxtInvVal() As Long
Dim varCurMaxInv
If IsNull(DMax("InvVal", "tblInvoice")) Then
MakeNxtInvVal = 1
Else
MakeNxtInvVal = DMax("InvVal", "tblInvoice") + 1
End If
End Function
Thanks in advance! I don't know what I would do without this forum!