unique autodate
Hi,
I would like to know if you could create a tutorial/snippet/behaviour/etc which shows creating a unique ID based on a date and text number fields on ASP. I would like to get the following:
03-06-002
which stands for 2nd entry request for the month of June, 2003.
I can make it work on my access forms.
I have a table with three main fields:
conumdate (text)
number (number)
(PK) controlnumber (text)
everything works (on access forms) once I click the 'add new record' button:
Private Sub cmdAdd_Click()
On Error GoTo Err_cmdAdd_Click
On Error GoTo Err_cmdAdd_Click
Dim LastRec, LastYM As Integer
Dim MyDate As String
Dim strYM As String
Dim YM, Num As String
Dim MyDate As String
Dim strYM As String
Dim YM, Num As String
'read from table the last number
LastRec = DLast("[number]", "test2date")
LastYM = DLast("[conumdate]", "test2date")
MyDate = Date
LastRec = DLast("[number]", "test2date")
LastYM = DLast("[conumdate]", "test2date")
MyDate = Date
'add the record
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToRecord , , acNewRec
'format to year and month (2 digits)
strYM = Format(MyDate, "yymm")
strYM = Format(MyDate, "yymm")
'changed based on month and year change
If strYM = LastYM Then
Num = LastRec + 1
Else
Num = "000"
End If
If strYM = LastYM Then
Num = LastRec + 1
Else
Num = "000"
End If
number.Value = Num
conumdate.Value = strYM
conumdate.Value = strYM
controlnumber.Value = strYM & Num
Exit_cmdAdd_Click:
Exit_cmdAdd_Click:
Exit Sub
Any help on making this work on ASP would surely be appreciated.
Thanks in advanced!
Comments
Be the first to write a comment
You must me logged in to write a comment.