Single Parameter Multiple Queries

saschmeling

New Member
Joined
Jun 27, 2012
Messages
39
Hi,


I have a base Query that pulls in data to be used in multiple queries.


Code:
  Select
    ClientActivities.FacilityID
    ,Facility.FacilityName
    ,ClientActivities.ClientID
    ,ClientActivities.ActivityID
    ,ClientActivities.ActivityDate
    From
    ClientActivities
    Inner Join
    Facility
    on
    ClientActivities.FacilityID = FAcility.FacilityID
    Where
    ClientActivities.ActivityDate Between [StartDate] and [EndDate]
This feeds two other Queries.


Code:
  Select
    FacilityName
    ,Count(ClientID) 
    From
    BaseQuery

and


Code:
   Select
    ActivityID
    ,Count(ClientID)
    From
    BaseQuery

When I put them both on a single report as subreports- it asks me for the StartDate and EndDate twice. I would like for it to ask only once. Any suggestions on how this can be done? While keeping it simple as once I turn this over to the user I will be leaving and the extent of their Access training is one college class.


Thanks,
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Have you tried altering your first query to select into a temporary table? The SELECT...INTO statement has these parts:
PartDescription
field1, field2The name of the fields to be copied into the new table.
newtableThe name of the table to be created. It must conform to standard naming conventions . If newtable is the same as the name of an existing table, a trappable error occurs.
externaldatabaseThe path to an external database . For a description of the path, see the IN clause.
sourceThe name of the existing table from which records are selected. This can be single or multiple tables or a query. Then change the two subqueries to select from the temporary table. When the second query is complete simply drop the temporary table. It's been a while since I've worked in Access but it works pretty well in SQL. Give it a try. The temporary table will be created when you run the first query using select into instead of select.

<tbody>
</tbody>
 
Upvote 0
if you put the parameters on a form and reference them from there, you can hide the form when you run the report and the parameters will be available to both queries.

On a form called frmFilter you could have a command button and put something like this in the Click event:

Code:
Private Sub SomeButton_Click()
   Me.Visible = False
   DoCmd.OpenReport "MyReport", acPreview
EndSub

Denis
 
Upvote 0

Forum statistics

Threads
1,216,581
Messages
6,131,546
Members
449,654
Latest member
andz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top