Pass query parameters through multiple queries

C

Chuck W

I have a module that opens up to 30 reports and prints each one. Each of
these reports is based on a parameter query that requires the user to enter a
date range.

Can anyone tell me how I can enter the date range one time and pass it
through to all of the reports that are being opened by the module?

Any help is greatly appreciated.
 
D

Douglas J. Steele

Create a form that has unbound text boxes to hold the start and end dates.
Have the query refer to those text boxes (using the syntax
Forms![NameOfForm]![NameOfControl]) rather than simply using named
parameters like [Start Date] and [End Date]. Make sure that the form is open
before the query runs: Access will not open the form for you.

If you want to get fancy, you can add a calendar to let your users select
the date, rather than having to key it in. Jeff Conrad lists a number of
possibilities at
http://www.accessmvp.com/JConrad/accessjunkie/calendars.html (Like Jeff, I
prefer the first option)
 
M

Marshall Barton

Chuck said:
I have a module that opens up to 30 reports and prints each one. Each of
these reports is based on a parameter query that requires the user to enter a
date range.

Can anyone tell me how I can enter the date range one time and pass it
through to all of the reports that are being opened by the module?


Parameter prompts are just a quick and dirty way to adjust a
query. A more robust approach is to use a form with text
boxes for the date range and a button to call your
procedure.

This way the query parameters would look like:
Forms!theform.sometextbox
 
C

Chuck W

You are the man, Douglas. That worked perfectly. Thank you very much.

I had no idea you could set up parameters like that.

Thanks again.

Douglas J. Steele said:
Create a form that has unbound text boxes to hold the start and end dates.
Have the query refer to those text boxes (using the syntax
Forms![NameOfForm]![NameOfControl]) rather than simply using named
parameters like [Start Date] and [End Date]. Make sure that the form is open
before the query runs: Access will not open the form for you.

If you want to get fancy, you can add a calendar to let your users select
the date, rather than having to key it in. Jeff Conrad lists a number of
possibilities at
http://www.accessmvp.com/JConrad/accessjunkie/calendars.html (Like Jeff, I
prefer the first option)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chuck W said:
I have a module that opens up to 30 reports and prints each one. Each of
these reports is based on a parameter query that requires the user to
enter a
date range.

Can anyone tell me how I can enter the date range one time and pass it
through to all of the reports that are being opened by the module?

Any help is greatly appreciated.
 
J

John W. Vinson

Can anyone tell me how I can enter the date range one time and pass it
through to all of the reports that are being opened by the module?

Instead of a prompt like [Enter start date:], use a little unbound Form,
frmCrit let's say, with textboxes; use a criterion
= [Forms]![frmCrit]![txtStartDate] AND < DateAdd("d", 1, [Forms]![frmCrit]![txtEndDate]

Put a button on the form to launch the code or macro which opens the reports.

John W. Vinson [MVP]
 

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