Passing Parameters from one query to another

N

norm

I have 2 queries that generate 2 reports, both queries ask for "starting
date" and "ending date" these reports are always run together. Is there a
way where the date parameters can be passed to the second query, with out
asking for user input a second time?
one query uses "Data_Assigned" and the other one uses "Date_Issued"

Thanks for your time and patience
 
F

fredg

I have 2 queries that generate 2 reports, both queries ask for "starting
date" and "ending date" these reports are always run together. Is there a
way where the date parameters can be passed to the second query, with out
asking for user input a second time?
one query uses "Data_Assigned" and the other one uses "Date_Issued"

Thanks for your time and patience

You'll need to use a form to do this.

First, create the queries that will display the fields you wish to
show in the report.

Second, create the reports, using a query as it's record source, that
shows the data you wish to display for ALL records.

Next, make a new unbound form.

Add 2 unbound text controls to the form.
Set their Format property to any valid date format.
Name one "StartDate".
Name the other "EndDate".

Add a command button to the form.
Code the button's Click event:
Me.Visible = False
Name this form "ParamForm"

Go back to each query.
As Criteria on the DateField, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate

Code the first Report's Open Event:
DoCmd.OpenForm "ParamForm" , , , , , acDialog

Code the second Report's Close event:
DoCmd.Close acForm, "ParamForm"

Run the first Report.
The report will open the form.

Enter the starting and ending dates.
Click the command button.

Both Report's will display just those records in the date range
selected.
When the second Report closes it will close the form.
 
N

norm

Sorry, But I am getting a little lost on the line:
DoCmd.OpenForm "ParamForm",,,,,,,acDialog
The report is opening fine, the report is opening fine, but it is not
accepting the date input
Thank you for your help.

I have 2 queries that generate 2 reports, both queries ask for "starting
date" and "ending date" these reports are always run together. Is there a
way where the date parameters can be passed to the second query, with out
asking for user input a second time?
one query uses "Data_Assigned" and the other one uses "Date_Issued"

Thanks for your time and patience

You'll need to use a form to do this.

First, create the queries that will display the fields you wish to
show in the report.

Second, create the reports, using a query as it's record source, that
shows the data you wish to display for ALL records.

Next, make a new unbound form.

Add 2 unbound text controls to the form.
Set their Format property to any valid date format.
Name one "StartDate".
Name the other "EndDate".

Add a command button to the form.
Code the button's Click event:
Me.Visible = False
Name this form "ParamForm"

Go back to each query.
As Criteria on the DateField, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate

Code the first Report's Open Event:
DoCmd.OpenForm "ParamForm" , , , , , acDialog

Code the second Report's Close event:
DoCmd.Close acForm, "ParamForm"

Run the first Report.
The report will open the form.

Enter the starting and ending dates.
Click the command button.

Both Report's will display just those records in the date range
selected.
When the second Report closes it will close the form.
 
F

fredg

Sorry, But I am getting a little lost on the line:
DoCmd.OpenForm "ParamForm",,,,,,,acDialog
The report is opening fine, the report is opening fine, but it is not
accepting the date input
Thank you for your help.



You'll need to use a form to do this.

First, create the queries that will display the fields you wish to
show in the report.

Second, create the reports, using a query as it's record source, that
shows the data you wish to display for ALL records.

Next, make a new unbound form.

Add 2 unbound text controls to the form.
Set their Format property to any valid date format.
Name one "StartDate".
Name the other "EndDate".

Add a command button to the form.
Code the button's Click event:
Me.Visible = False
Name this form "ParamForm"

Go back to each query.
As Criteria on the DateField, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate

Code the first Report's Open Event:
DoCmd.OpenForm "ParamForm" , , , , , acDialog

Code the second Report's Close event:
DoCmd.Close acForm, "ParamForm"

Run the first Report.
The report will open the form.

Enter the starting and ending dates.
Click the command button.

Both Report's will display just those records in the date range
selected.
When the second Report closes it will close the form.

This is what I wrote:
DoCmd.OpenForm "ParamForm" , , , , , acDialog

Note the 5 commas. They're important.

This is what you wrote:
DoCmd.OpenForm "ParamForm",,,,,,,acDialog

Note the 7 commas. Remove 2 of them.
Then read VBA help on the arguments used in then OpenForm method.
 

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