I am trying to add an incrementing 4 digit number to the middle of a
string. The incrementing number is not working. There must be a better
way of writing this. The result I would like should look like this:
Invoice_no is the field in my test_no table. The value should look like this: LB-0001-02 Where LB is static, 0001 is the incrementing number and 02
is the year. Here is a sample of my code:
Private Sub Form_Current()
Dim intYearDiff As Integer
intYearDiff =format(Date,"yy"
-Left(DMax("[Invoice_no]","testno"
,4)
If Me.NewRecord Then
Select Case intYearDiff
Case 0
Me.[Invoice_no]=DMax ("[invoice_no]","testno"
+ 1
Case 1
Me.[Invoice_no]=Format(Date, "yy"
&"0001"
End Select
End If
End Sub
Any help on this qould be greatly appreciated.
string. The incrementing number is not working. There must be a better
way of writing this. The result I would like should look like this:
Invoice_no is the field in my test_no table. The value should look like this: LB-0001-02 Where LB is static, 0001 is the incrementing number and 02
is the year. Here is a sample of my code:
Private Sub Form_Current()
Dim intYearDiff As Integer
intYearDiff =format(Date,"yy"
If Me.NewRecord Then
Select Case intYearDiff
Case 0
Me.[Invoice_no]=DMax ("[invoice_no]","testno"
Case 1
Me.[Invoice_no]=Format(Date, "yy"
End Select
End If
End Sub
Any help on this qould be greatly appreciated.