C
ckrogers
Hi. Just FYI -- I'm fairly new to VB programming.... I usually copy code
that is working and make changes from there....
I'm trying to automatically assign a quote number with the following format:
(yyyymm-xxxx) where "xxxx" is a sequential number to be re-set annually.
So, the numbers will go from 200601-0001 to 200612-9999.
Here's the code I'm using:
Dim varNextNum As Variant
Dim strQuotePrefix As String
Dim strQuoteYear As String
strQuoteYear = Format(Date, "yyyy")
strQuotePrefix = Format(Date, "yyyymm") & "-"
varNextNum = DMax("[Quote_Number]", "tbl_Quote_Information", _
Left([Quote_Number], 4) = "'" & strQuoteYear & "'")
varNextNum = IIf(IsNull(varNextNum), 1, Right(varNextNum, 4) + 1)
Me.[PRP_Quote_No] = strQuotePrefix & Format(varNextNum, "0000")
I'm getting the error "Run-time error '2465': Microsoft Access can't find
the field '|' referred to in your expression." The Debug is highlighting the
two lines starting with "varNextNum = DMax".
I definitely have the field "Quote_Number" in the table
"tbl_Quote_Information". I am trying to fill in the field "PRP_Quote_No" in
a different table....
Can anyone help with what I'm doing wrong?
Thanks!
Cindy
that is working and make changes from there....
I'm trying to automatically assign a quote number with the following format:
(yyyymm-xxxx) where "xxxx" is a sequential number to be re-set annually.
So, the numbers will go from 200601-0001 to 200612-9999.
Here's the code I'm using:
Dim varNextNum As Variant
Dim strQuotePrefix As String
Dim strQuoteYear As String
strQuoteYear = Format(Date, "yyyy")
strQuotePrefix = Format(Date, "yyyymm") & "-"
varNextNum = DMax("[Quote_Number]", "tbl_Quote_Information", _
Left([Quote_Number], 4) = "'" & strQuoteYear & "'")
varNextNum = IIf(IsNull(varNextNum), 1, Right(varNextNum, 4) + 1)
Me.[PRP_Quote_No] = strQuotePrefix & Format(varNextNum, "0000")
I'm getting the error "Run-time error '2465': Microsoft Access can't find
the field '|' referred to in your expression." The Debug is highlighting the
two lines starting with "varNextNum = DMax".
I definitely have the field "Quote_Number" in the table
"tbl_Quote_Information". I am trying to fill in the field "PRP_Quote_No" in
a different table....
Can anyone help with what I'm doing wrong?
Thanks!
Cindy