What is my syntax problem in this statement?
DoCmd.OpenReport strDocName, acViewPreview, ,[ReportNumber] Between [forms]![Get Print Batch]![BegReport] And [forms]![Get Print Batch]![EndReport]
Thanks again
What is my syntax problem in this statement?
DoCmd.OpenReport strDocName, acViewPreview, ,[ReportNumber] Between [forms]![Get Print Batch]![BegReport] And [forms]![Get Print Batch]![EndReport]
Thanks again
I have now changed the statement to:
DoCmd.OpenReport strDocName, acViewPreview, , "ReportNumber Between" & Me.[Forms]![Get Print Batch]![BegReport] & "And" & Me.[Forms]![Get Print Batch]![EndReport]
And get "Microsoft Office cannot find the field '|' referenced in your expression."
Your string will evaluate to:
ReportNumber Between123And456
See where you need to add some spaces? Also, you either use "Me" or the full form reference, not both.
I am a bit limited on when to use what syntax.
Try
DoCmd.OpenReport strDocName, acViewPreview, , "ReportNumber Between " & [Forms]![Get Print Batch]![BegReport] & " And " & [Forms]![Get Print Batch]![EndReport]
Bingo!! Thanks!! I didn't realize the spaces were that important...
Happy to help. How is Access to know where one thing ends and the next begins without spaces? You and I can look at it and intuitively know, but Access can't. The error you got was Access's way of throwing up it's hands and saying "I don't understand!"