Using Access 2007, I need to create an automatic Serial Number. I am new to Access and with no knowledege of writing codes.
Example "7235-4300"
"7" will be the current year
"235" is day (Julian Date)
"-43" is static
"01" (SerialNo) is sequential, restarting at "01" each day
I have searched the forum and found a detail explanation of the code and it works. However, the code did not provide how to get the 01 restarted each day.
Code from the previous post:
Example "7235-4300"
"7" will be the current year
"235" is day (Julian Date)
"-43" is static
"01" (SerialNo) is sequential, restarting at "01" each day
I have searched the forum and found a detail explanation of the code and it works. However, the code did not provide how to get the 01 restarted each day.
Code from the previous post:
Code:
Public Function fGenerateNextSerialNumber()
Dim strCurrentYear As String
Dim strCurrentDay As String
Dim strStaticValue As String
Dim strSequentialNo As String
Dim strLastSerialNo As String
Dim strLastSequentialNo As String
Dim strNextSequentialNo As String
strCurrentYear = Right(Year(Now()), 1)
strCurrentDay = DateDiff("d", CDate("1/1/" & Year(Now())), Now()) + 1
strStaticValue = "-43"
'get ready to extract the Sequential Number
strLastSerialNo = DLast("[SerialNo]", "tblTest") 'produces 7235-4300
strLastSequentialNo = Right(strLastSerialNo, 2) 'produces 01
'Generate the Next Sequential Number
strNextSequentialNo = Format(Val(strLastSequentialNo) + 1, "00") 'produces "02"
'Generate the next, Unique, Serial #
fGenerateNextSerialNumber = strCurrentYear & strCurrentDay & strStaticValue & strNextSequentialNo
End Function
Comment