Setting Subreport filters from Parent Filter

Chris Morris

Registered User.
Local time
Today, 23:23
Joined
May 3, 2011
Messages
20
I have a report which is opened using a DoCmd.OpenReport. There's a criteria string which filters the main report - this works fine.

There's now a requirement to place a summary subform at the beginning of the report, in the report header. I need that summary to use the same criteria string as the main report.

For the main report's OnLoad I put:

Me!Expenditure_By_Type_Subreport.Report.Filter = Me.Filter

But I get the error message:
Error 2101
The setting you entered isn't valid for this property.

I tried it the other way round as well - in the OnOpen of the subreport I tried:
Me.Filter = Me.Parent.Filter
And it gives the same error.

When I just a manual Filter change such as:
Me.Filter = "Project_ID Is Not Null"
 
If the filter string is coming from docmd.openreport (as opposed to being 'hardcoded')I suspect that the filter string has not been assigned when you run the code so it is trying to assign null or empty

subforms and subreports load before the main form/report so having the code there will definitely generate an error

suggest you step through the code noting when the filter string becomes available on the main report - you may need to use a different event such as current.
 
Thanks for that - it certainly gave me some leads, but it still didn't like it. I've got round it by opening the subform as Hidden, changing its Filter setting to the stCriteria, closing and saving and then running the main report. It's slightly messier than I thought it would be, but it works well without much delay.

Thanks again.
 
just noticed - you are talking about subforms rather than subreports in a report - if it is a subform then you would use

Me!Expenditure_By_Type_Subreport.Form.Filter = Me.Filter
 

Users who are viewing this thread

Back
Top Bottom