A
Andy
Hi there,
I have a table "check no" and code as below :
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim MYRECORDSET, MYLOOKUP As Variant
Dim NUMBER As Variant
MYLOOKUP = DLookup("THE_DATE", "CHECK NO")
If IsNull(MYLOOKUP) Then
Set MYRECORDSET = CurrentDb.OpenRecordset("CHECK NO")
MYRECORDSET.AddNew
MYRECORDSET("THE_DATE") = DATE
MYRECORDSET("NO") = 1
MYRECORDSET.Update
NUMBER = 1
End If
If MYLOOKUP = DATE Then
Set MYRECORDSET = CurrentDb.OpenRecordset("CHECK NO")
NUMBER = MYRECORDSET("NO") + 1
MYRECORDSET.Edit
MYRECORDSET("NO") = NUMBER
MYRECORDSET.Update
ElseIf MYLOOKUP < DATE Then
Set MYRECORDSET = CurrentDb.OpenRecordset("CHECK NO")
MYRECORDSET.Edit
MYRECORDSET("THE_DATE") = DATE
MYRECORDSET("NO") = 1
MYRECORDSET.Update
NUMBER = 1
End If
Me![INVOICE NO] = "WS-" & Format(DATE, "YYMM") & Format(NUMBER, "000")
End Sub
I would like the [invoice no] show
"WS-0711001","WS-0711002","WS-0711003"..... the problem is that it is always
indicate "WS-001" only, I found that the table field of [the_date] is till
null after the code run.
Appreciate for your expert comments. Thanks in advance!
(Access 2002 SP3 / Window XP SP2)
I have a table "check no" and code as below :
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim MYRECORDSET, MYLOOKUP As Variant
Dim NUMBER As Variant
MYLOOKUP = DLookup("THE_DATE", "CHECK NO")
If IsNull(MYLOOKUP) Then
Set MYRECORDSET = CurrentDb.OpenRecordset("CHECK NO")
MYRECORDSET.AddNew
MYRECORDSET("THE_DATE") = DATE
MYRECORDSET("NO") = 1
MYRECORDSET.Update
NUMBER = 1
End If
If MYLOOKUP = DATE Then
Set MYRECORDSET = CurrentDb.OpenRecordset("CHECK NO")
NUMBER = MYRECORDSET("NO") + 1
MYRECORDSET.Edit
MYRECORDSET("NO") = NUMBER
MYRECORDSET.Update
ElseIf MYLOOKUP < DATE Then
Set MYRECORDSET = CurrentDb.OpenRecordset("CHECK NO")
MYRECORDSET.Edit
MYRECORDSET("THE_DATE") = DATE
MYRECORDSET("NO") = 1
MYRECORDSET.Update
NUMBER = 1
End If
Me![INVOICE NO] = "WS-" & Format(DATE, "YYMM") & Format(NUMBER, "000")
End Sub
I would like the [invoice no] show
"WS-0711001","WS-0711002","WS-0711003"..... the problem is that it is always
indicate "WS-001" only, I found that the table field of [the_date] is till
null after the code run.
Appreciate for your expert comments. Thanks in advance!
(Access 2002 SP3 / Window XP SP2)