A slick way is to create a small form that offers the three choices, say in a list box. The user chooses one and then clicks an OK button. The cmdOK_Click procedure then assigns the name of the corresponding query to the Reports![ReportName].RecordSource property, then closes the form. (If the user didn't choose one before clicking OK, you instead just give them a message box and exit the Click procedure.) It's also nice to give the user a Cancel button. If they click that, set the report's RecordSource property to an empty string and close the form.
To integrate this into the report opening process, just have your Report_Open procedure open the form. Be sure to specify that you want it opened in dialog mode, so that the report will stop and wait for the user to choose. If you included a Cancel button on the form, then after doing the OpenForm (in Report_Open) you should check whether the RecordSource property is empty, meaning the user canceled the dialog form. If so, set the Report_Open's Cancel argument to true, then exit. The report will then just close down without displaying anything.
What the user will see, upon choosing the report (in either the Database Window or on a form that does OpenReport), is your little dialog form asking which records they want to see on the report. When they choose one and click OK, the report will open with a blank window, and then the query will ask for the parameters. After the parameters are entered, the report window will display the completed report preview. If the user clicked Cancel on the dialog, the dialog just disappears and the report never appears. Rick Sprague
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.