Please help me debug the following. The problem appears to be with my SQL statement, as I get the error:
"Run-time error '2342':
A RunSQL action requires an argument consisting of an SQL statement."
Here is the code (with MsgBox added to help me keep track; both come out correct):
sCurMonth = Right(CStr(10000 + Year(Date)), 4) + Right(CStr(100 + Month(Date)), 2)
MsgBox "sCurMonth is " & sCurMonth
strGeneric = "'" & sCurMonth & Chr(37) & "'"
MsgBox "strGeneric is " & strGeneric
sequel = "SELECT TOP 1 Right([RefNumber], 2) FROM SPRRTable WHERE [RefNumber] LIKE strGeneric"
DoCmd.RunSQL "SELECT TOP 1 Right([RefNumber], 2) FROM SPRRTable WHERE [RefNumber] LIKE strGeneric"
I've tried it with the statement DoCmd.RunSQL sequel and with the longer bit.
Thank you!
"Run-time error '2342':
A RunSQL action requires an argument consisting of an SQL statement."
Here is the code (with MsgBox added to help me keep track; both come out correct):
sCurMonth = Right(CStr(10000 + Year(Date)), 4) + Right(CStr(100 + Month(Date)), 2)
MsgBox "sCurMonth is " & sCurMonth
strGeneric = "'" & sCurMonth & Chr(37) & "'"
MsgBox "strGeneric is " & strGeneric
sequel = "SELECT TOP 1 Right([RefNumber], 2) FROM SPRRTable WHERE [RefNumber] LIKE strGeneric"
DoCmd.RunSQL "SELECT TOP 1 Right([RefNumber], 2) FROM SPRRTable WHERE [RefNumber] LIKE strGeneric"
I've tried it with the statement DoCmd.RunSQL sequel and with the longer bit.
Thank you!