Using parametered query in report

  • Thread starter Thread starter MLP
  • Start date Start date
M

MLP

I created a complicated parameter query and I want to use this as
a recordsource for my report. Does anyone know how I can pass
the values of the parameters to the report?

The query name is "qryGetRecord" and I use this query name in the
recordsource of the report. When it runs, it prompts for the
values of the parameters like it should. How can I pass the
values in run-time to the report without seeing the dialog box?

Thanks for the help.

ML
 
I am using VBA Code and here is some of my code in the
report_open event:

Dim qdf As QueryDef
Set qdf = CurrentDb.QueryDefs("qryPremiumAnalysis")

qdf!parmYearID = 6
qdf!parmCityID = 24

Me.RecordSource = qdf

When I run this, I got a compile error at the last time: Type
mismatch.

I must be doing something wrong but I don't want not. Thanks for
your help.

Mei-Ling


John said:
How can I pass the
values in run-time to the report without seeing the dialog box?


The simplest way (IMO) is to replace prompts such as [Enter account
number:] with references to a Form, e.g.

=[Forms]![frmCriteria]![cboAccountNo]

pointing to an unbound combo box cboAccountNo on an unbound form
frmCrit. Have all the other criteria on the form, and launch the
report from a form button.

If you have the criteria available in VBA code, you can use the
Query's Parameters collection to set them.
 
Back
Top