LarsDyrby
asked on
Passing criteria into a report from a form
I have a query (qry_report1) and a report (rpt_report1) that requires 2 inputs from the user - StartDate and EndDate. I have set up a form (frm_report) with 2 txt fields with datepickers where the user can set the dates. I have made a command button calling the report using DoCmd.OpenReport.
When I open frm_report and set the dates and press the button the setup works, but when I embed the frm_report in a navigationalform (frm_menu) and run it from here it doesn't work anymore. Instead I keep getting the enter parameter value dialogue box.
Whats the problem?
When I open frm_report and set the dates and press the button the setup works, but when I embed the frm_report in a navigationalform (frm_menu) and run it from here it doesn't work anymore. Instead I keep getting the enter parameter value dialogue box.
Whats the problem?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the criteria in your query "qry_report1" is still looking for the form "frm_report" which now became a sub form when you placed it in "frm_Menu"..
1. remove the date criteria from your query
2. open the report like this
docmd.openreport "rpt_report1",,, "[datefrom]>=#" & me.textdate1 & "# and [dateTo]<=#" & me.textdate2 & "#"
that is the format you should use...
post the criteria from query "qry_report1", so we can correct the code above
.
1. remove the date criteria from your query
2. open the report like this
docmd.openreport "rpt_report1",,, "[datefrom]>=#" & me.textdate1 & "# and [dateTo]<=#" & me.textdate2 & "#"
that is the format you should use...
post the criteria from query "qry_report1", so we can correct the code above
.
If you want to refer to the original form, which is now a subform of another form, you can refer to it in this way
Forms!frm_menu.form!frm_re port!txtFi eld1
OM Gang
Forms!frm_menu.form!frm_re
OM Gang
OM Gang