I have a screen showing several report icons. It would be nice if many of these reports were filtered by month and year to limit the size of the reports to data of interest. What I'd like to do is have the user select the report icon, bring up a small form so he can choose the month and year, then run the query to filter the data for the report. I'm wondering if I can use the same Month_Year_Form for each of my reports (or am I forced to use a seperate Month_Year_Form for every report?
The problem I'm running into is when I run my program, using the code shown below that's initiated by selecting the desired report icon from my main reports menu, the program doesn't stop and wait for the form to be filled in. It simply brings up an "empty" report. How can I get the code to stop and wait for the user to press the "continue" button on the Month_Year_Form so that the query will have the parameters necessary to build the report appropriately?
I know I could do this if I had a seperate Month_Year_Form for each report since I could put the code to run the report from the "continue" button on my Month_Year_Form. But having all of these Month_Year_Forms would be inefficient. Is there a way I can set up a variable for the report I want to run based on the icon selected from the main reports screen and use the variable to run the report from the Month_Year_Form's continue button?
This is my current code: I'd like the code to stop and wait for the continue button to be selected on my Month_Year_Form, but it just keeps running....
Private Sub Discovery_Click()
On Error GoTo Err_Discovery_Click
Dim stDocName As String
Dim stDocName2 As String
stDocName = "Discovery Process"
stDocName2 = "Month_Year_Form"
DoCmd.OpenForm stDocName2
DoCmd.Maximize
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize
Exit_Discovery_Click:
Exit Sub
Err_Discovery_Click:
MsgBox Err.Description
Resume Exit_Discovery_Click
End Sub
The problem I'm running into is when I run my program, using the code shown below that's initiated by selecting the desired report icon from my main reports menu, the program doesn't stop and wait for the form to be filled in. It simply brings up an "empty" report. How can I get the code to stop and wait for the user to press the "continue" button on the Month_Year_Form so that the query will have the parameters necessary to build the report appropriately?
I know I could do this if I had a seperate Month_Year_Form for each report since I could put the code to run the report from the "continue" button on my Month_Year_Form. But having all of these Month_Year_Forms would be inefficient. Is there a way I can set up a variable for the report I want to run based on the icon selected from the main reports screen and use the variable to run the report from the Month_Year_Form's continue button?
This is my current code: I'd like the code to stop and wait for the continue button to be selected on my Month_Year_Form, but it just keeps running....
Private Sub Discovery_Click()
On Error GoTo Err_Discovery_Click
Dim stDocName As String
Dim stDocName2 As String
stDocName = "Discovery Process"
stDocName2 = "Month_Year_Form"
DoCmd.OpenForm stDocName2
DoCmd.Maximize
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize
Exit_Discovery_Click:
Exit Sub
Err_Discovery_Click:
MsgBox Err.Description
Resume Exit_Discovery_Click
End Sub