Hello!
I have an Access report titled JobTicket1Auto that in the query had Between [BeginningOrder] And [EndingOrder] as criteria which prompts the user to enter a value for BeginningOrder and EndingOrder. Works fine.
I want to automate this report and have tried the following:
Code:
strSql = "SELECT * FROM Orders WHERE OrderId BETWEEN " & [First] & " and " & [Last]
Debug.Print strSql
'(in the immediate window appears SELECT * FROM Orders WHERE OrderId BETWEEN 6474 and 6475)
DoCmd.OpenReport ReportName:="JobTicket1Auto", View:=acViewReport, WhereCondition:=strSql
DoCmd.PrintOut
DoCmd.Close
Here's the error window text:
Run-time error '3075:
Syntax error in query expression 'SELECT * From Orders WHERE OrderId BETWEEN 6475 and 6476'.
What is the syntax error?
THANKS in advance!
Bud