Subreport needs same dynamic filter as main report

  • Thread starter Thread starter M Skabialka
  • Start date Start date
M

M Skabialka

I have a main report where it is opened using a filter which is created on a
form based on user selection of vehicles and repair items.
DoCmd.OpenReport stDocName, acViewPreview, , Me!strSQL
I have added a subreport to summarize the data in the main report:

If they chose Vehicle 1 and 2 , and want to know how many wheels, windows,
wipers and door were replaced (based on selections from multi-select list
boxes), the report and sub-report should show:

Vehicle 1 repairs
Wheels 2
Windows 1
Wipers 2
Vehicle 2 repairs
Wheels 4
Doors 1
Summary sub-report
Wheels 6
Windows 1
Wipers 2
Doors 1

The main report is filtering properly - the sub-report is counting all
vehciles and all repairs. If I link master or child with either vehicleID
or repairItem, it only summarizes the last vehicle.

How do I filter the subreport the same as the main report, ie, using
Me!strSQL, or link it somehow?
Mich
 
M said:
I have a main report where it is opened using a filter which is created on a
form based on user selection of vehicles and repair items.
DoCmd.OpenReport stDocName, acViewPreview, , Me!strSQL
I have added a subreport to summarize the data in the main report:

If they chose Vehicle 1 and 2 , and want to know how many wheels, windows,
wipers and door were replaced (based on selections from multi-select list
boxes), the report and sub-report should show:

Vehicle 1 repairs
Wheels 2
Windows 1
Wipers 2
Vehicle 2 repairs
Wheels 4
Doors 1
Summary sub-report
Wheels 6
Windows 1
Wipers 2
Doors 1

The main report is filtering properly - the sub-report is counting all
vehciles and all repairs. If I link master or child with either vehicleID
or repairItem, it only summarizes the last vehicle.

How do I filter the subreport the same as the main report, ie, using
Me!strSQL, or link it somehow?


I suggest that you change the subrepotr's record source
query to use the same criteria as the main report's query.

Trying to do that on the fly can get complicated.
 
I am now deleting and recreating the entire control source query for the
sub-report each time the report is run, based on the user criteria. The
report uses the filter, the subreport uses a new query each time it runs.
Problem solved.
Mich
 
Back
Top