running report based on results of QBF

G

Guest

Hi,
I have a form that is used to collect parameters for a query (QBF). The form
works fine but how to do I pass the results to a report? I tried using the
report wizard and based te report on the query but instead of using my form
to enter the parameters, several input boxes are displayed prompting the user
for the parameters.

Thanks,
 
P

PC Datasheet

Leave the record source of the report blank.

Put the following code in the Open event of the report:
DoCmd.OpenForm "NameOfParameterForm",,,,,acDialog
Me.Recordsource = "NameOfQuery"
DoCmd.Close acForm, "NameOfParameterForm"

Create a button on your parameter form and put the following code in the
Click event of the button:
Me.Visible = False
 
G

Guest

I'm not sure what I'm doing wrong but I the input boxes are still displayed
in addition to the parameter collection form.

Is there a tutorial or sample files I can download from somewhere?

Thanks,
Scott
 
G

Gavin Blackford

Hi,

There are a couple of ways to do this. The easiest is in your query to
point the criteria to your form eg

if you had a field called Year in your query you would enter in the
Criteria field the following (expection form to be called frmConditions
and Control to be called txtYear)

Forms![frmConditions]![txtYear]

you can also get more complex my adding conditions like:

Like Forms![frmConditions]![txtYear] & '*'

But this does slow your query down, but the user only has to enter the
start.

Also for this to work, you have to open the form before running the
report, I find the easiest way to do it is to open the form and have a
button on the form to call the report.

Hope this helps.

Gavin,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top