filter subreport from form

joepineapples

Registered User.
Local time
Today, 18:47
Joined
Apr 28, 2006
Messages
29
Hi All

I have a report called Services. Within the Header I have a Subreport called Performance_Indicators

What I would like to be able to do is filter this subreport report using a combobox from a form.

I can filter the main report using this method but not the subreport - can this be done?

Any help would be much appriciated.

JP
 
Hi All

I have a report called Services. Within the Header I have a Subreport called Performance_Indicators

What I would like to be able to do is filter this subreport report using a combobox from a form.

I can filter the main report using this method but not the subreport - can this be done?

Any help would be much appriciated.

JP

It should be possible to do.

How are you filtering the data? Are you using a form reference in the report's Record source?
 
I have a an open report button which contains the following code:

Code:
Dim stDocName

stDocName = "rptServices"

DoCmd.OpenReport stDocName, acViewPreview, , "Service = '" & cboService & "'"

In the above case 'Service' is a field in both the form and the report. This is the bit that works.

I also have is another field called 'Indicator' which is on the form and also in the subreport 'Performance_Indicators' (This is linked to the 'Services' report by the field 'Service') This is the bit I need help with - can I reference this in a similar way to the above example so that I can filter the Servives report to show only the Services that have indicators as filtered by indicator?
 
You could set the report filter in the Open event. I use a Global variabel to hold the filterstring while
the report execute and release it afterwards.

Private Sub Report_Open(Cancel As Integer)
If gstrReportFilter <> vbNullString Then
Me.filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = vbNullString
End If
End Sub

With this setup what you must do is to pass the textstring to gstrReportFilter and then execute your OpenReport
statement. The filterstring would look like : (Indicator = .....)

Public gstrReportFilter as String <- Global variabel.
This may be overkill for 1 report but you can use this methode if you got several reports with the same setup.

JR
 
Hi JR

I'm not sure this is going to work - I assume I would add the Report_Open code to the Main Report and not the Sub Report?

My aim is to filter the main report to only show Services that contain indicators from the filtered Sub Report.

Hopefully this makes sense?
 

Users who are viewing this thread

Back
Top Bottom