How do I get a filter to apply to all my subreports?

T

Tony Williams

This is an update from my previous post as things have changed.
I have a report that is made up of 6 subreports. I have a front end form
that filters the records for my main report by company and a date range. All
the subreports are linked to the main report with the field txtcompany. The
filter seems to filter my main report and subreports by company but not the
date range. How can I get the date range filter to apply to all the
subreports?
The code on my command button that contains the filter criteria is
Private Sub cmdOK_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.

Const conDateFormat = "\#mm\/dd\/yy\#"

strReport = "rptsense3"
strField = "txtmonthlabel"



If IsNull(Me.txtstartdate) Then
MsgBox "You must enter a start date", vbOKOnly, "Missing Start Date"
Me.txtstartdate.SetFocus
Else

If IsNull(Me.txtenddate) Then
MsgBox "You must enter an end date", vbOKOnly, "Missing End Date"
Me.txtenddate.SetFocus
Else
strWhere = strField & " Between " & Format(Me.txtstartdate,
conDateFormat) _
& " And " & Format(Me.txtenddate, conDateFormat)


If Not IsNull(Me.cmbselectcompany) Then
strWhere = strWhere & " AND cmbCompany = """ & Me.cmbselectcompany & """"
End If

DoCmd.OpenReport strReport, acViewPreview, , strWhere
End If
End If
End Sub

Any help would be appreciated.
Thanks
Tony
 
T

Tony Williams

Sorry guys done it again! Posted a question then figured out how to do it
afterwards. I used the filter in the query on which my reports were based.
Simple really but you know, sometimes you just can't see the obvious can
you?
Thanks anyway
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top