filter and filteron for reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good afternoon,

I'm having a little trouble with the filter and filteron commnand for
reports. If I run my report directly evrything works like a charm! However,
the report in question is meant to be a subreport of a much larger report.
When the Main report is run I always get an error and the Me.Filter line get
highlighted? What is wrong? What is the proper approach to apply a filter
to a subreports data?

Thank you,

Daniel
 
As you found, applying a Filter to a subreport doesn't work.

Some Options:

1. Change the subreport's query
You may be able to add the criteria to the query that feeds the subreport.

For example, if you want to filter the subreport to a date range, you could
create a form with a couple of text boxes to hold the dates. In the date
field in the subreport's query, enter:
Between [Forms].[Form1].[txtStartDate] And [Forms].[Form1].[txtEndDate]

2. Modify the LinkMasterFields/LinkChildFields
If the subreport shares a filter with the main report, you may be able to
add a text box to the main report, add that text box name to
LinkMasterFields, and use that to filter the subreport.

For example, the text box in the main report might have a Control Source of:
([ClientID] Is Not Null)
and the matching text box in the subreport has a Control Source of just:
=1
The subreport one is always true, so they match when the main report's
condition is True.

3. Modify the subreport's query before it opens.
If nothing else works, you can provide a command button to open the report,
and actually change the subreport's query's SQL before it opens.

This kind of thing:
dbEngine(0)(0).QueryDefs("Query1").SQL = "SELECT ...
DoCmd.OpenReport "Report1", acViewPreview
 
Back
Top