Is there a way to pass a value to a report via VBA so the value can then be displayed in the report as a concantenation with a string?
I have a report that displays all pricings that have occured in one day. I would like to display the pricing date in the report header. However, if there were no pricings for the date being viewed, I return no records so I can't pull the pricing date from my query results and thus want to set it programatically .
The form to display the pricing reports has two buttons. One for 'display today's pricings' and another for 'display pricings for x date'. Both buttons open the same report and the OpenReport command includes Where criteria to show only the desired date's data. With the exception of the db admin, all users will only ever look at pricings for the current day so the 'display today's pricings' button has:
The db admin will sometimes need to view past pricing reports so the 'display pricings for x date' button has:
I could have all users use the inputbox and set the inputbox default to Date then move all the code to the Report_Open event, but that means the majority of users will always have to click an extra button in the process of viewing the day's report.
In the Report_Open event, I want to do something like:
So is there a way I can pass the value for datReportDate to the Report_Open event as either the current day's date if user clicked 'view today's date' or as the user-entered date if user clicked 'view pricings for x date'? I apologize for the long post. The answer seems like it should be simple but, at this point, I'm so backwards in cleaning up this database I inherited that I can't see straight.
I have a report that displays all pricings that have occured in one day. I would like to display the pricing date in the report header. However, if there were no pricings for the date being viewed, I return no records so I can't pull the pricing date from my query results and thus want to set it programatically .
The form to display the pricing reports has two buttons. One for 'display today's pricings' and another for 'display pricings for x date'. Both buttons open the same report and the OpenReport command includes Where criteria to show only the desired date's data. With the exception of the db admin, all users will only ever look at pricings for the current day so the 'display today's pricings' button has:
Code:
strCriteria = "PricingDate = Date()" DoCmd.OpenReport "DailyPricings", acViewPreview, , strCriteria
Code:
strReportDate = InputBox("Please enter the desired report date", "Report Date", Date-1) strCriteria = "PricingDate = #" & strReportDate & "#" DoCmd.OpenReport "DailyPricings", acViewPreview, , strCriteria
In the Report_Open event, I want to do something like:
Code:
Dim strHeader as String strHeader = "2008 Pricings for " & datReportDate Me.lblHeader.Caption = strHeader
Comment