Reset Incrementing Number

yang0837

New member
Local time
Today, 14:38
Joined
Dec 21, 2011
Messages
4
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.

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! :)
 
Never mind! I figured it out. :)

Code:
Public Function MakeNxtInvVal() As Long
Dim varCurMaxInv
If IsNull(DMax("InvVal", "tblInvoice")) Then
    MakeNxtInvVal = 1
Else
    MakeNxtInvVal = Format(Nz(DMax("InvVal", "tblInvoice", "InvDate=Date()"), 0) + 1)
End If
End Function
 

Users who are viewing this thread

Back
Top Bottom