Scamquist
asked on
Run Access 2007 report based on query using a dialog box to supply the criteria
I have a report COMMUNICATION BY LOCATION that uses the query CommLine, which is based on the dialog box SelComTypeLoc.
The criteria for the query is [Forms]![SelComTypeLoc]![c Loc]
When I open the dialog box SelComTypeLoc and enter my value (cLoc) into a drop down box, the query executed properly.
I am trying to open the report and run it based on the values set in the dialog box SelComTypeLoc to run the query CommLine.
The report record source cannot be the form SelComTypeLoc.
How can I have the report run the dialog box to select the query values?
The criteria for the query is [Forms]![SelComTypeLoc]![c
When I open the dialog box SelComTypeLoc and enter my value (cLoc) into a drop down box, the query executed properly.
I am trying to open the report and run it based on the values set in the dialog box SelComTypeLoc to run the query CommLine.
The report record source cannot be the form SelComTypeLoc.
How can I have the report run the dialog box to select the query values?
ASKER
If I remove the paramaters from the query, the report will run with CommLine as the record source in the report. I know the dialog box works because if I open the form SelComTypeLoc first, enter my value and click OK the proper value is returned on the query. I am trying to open the report and run the query based on the dialog box in one smooth step.
One other piece, I am using a command button on another form to kick off the report...if that makes any difference.
One other piece, I am using a command button on another form to kick off the report...if that makes any difference.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OUTSTANDING!
Thank you for your help, The attached file saved the day. I found the link you provided, which is how I got as far as I did. However, the code they use is to have the OK button run the query, not open the report. The OK button on my dialog box was opening the query, not the report. I made the change and it worked like a champ. Thank you again.again.
Thank you for your help, The attached file saved the day. I found the link you provided, which is how I got as far as I did. However, the code they use is to have the OK button run the query, not open the report. The OK button on my dialog box was opening the query, not the report. I made the change and it worked like a champ. Thank you again.again.
I would change the Recordsource property of the form during the Open event using VBA code. Something like:
Report.Recordsource = "SELECT * FROM MyTable WHERE Criteria = ' & Forms]![SelComTypeLoc]![cL
I'm sure you'll need to tweak that a little...