Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
DoCmd.OpenReport MS Access with Parameters?
I am attempting to open a report in preview mode which has a single parameter of [BillingPeriod] type Text. Here is the code that I have however, it will not work.
lstSQL is a selection box, I know that it is pulling the correct selection. However, when I run the code I get the following error:
Syntax error (missing operator) in query expression '(2Q2007)'.
Dim stDocName As String
Dim BillingPeriod As String
BillingPeriod = Me.lstSQL
stDocName = "Billing Statement"
DoCmd.OpenReport stDocName, acPreview, , BillingPeriod
3 Answers
- BlueFeatherLv 61 decade agoFavorite Answer
It looks like you are trying to open a report by some kind of action on a form.
(click a command button or select an item from lstSQL)
What is lstSQL -- ComboBox or ListBox?
("selection box" is not appropriate terminology for either)
I assume you mean ComboBox; therefore the code would be:
DoCmd.OpenReport "Billing Statement", acViewPreview, , "BillingPeriod = " & Me.lstSQL
§
Note: before executing the DoCmd statement, your code should first check to ensure that an item has, in fact, been selected. (either that or put the statement into the OnClick event for lstSQL)
You won't need "BillingPeriod = Me.lstSQL" or stDocName
- RachelLv 61 decade ago
I don't know the answer - but I bet that someone on google groups would know. Whenever I have access questions I search on there and can usually find the answer. Good luck.