View Full Version : Filter SubForm and Report


Nizar
01-05-2008, 09:43 AM
Hello everyone,

I'm trying to filter a report based on previous filter of a subform.
I use this Code to Filter the subform
Private Sub Filter_Click()
Dim strWhere As String
If Not IsNull(Me.Coordinator) Then
'Create Predicate
strWhere = strWhere & " AND " & "Orders.[EmployeeID] = " & Me.Coordinator & ""
End If
If Not IsNull(Me.Customer) Then
'Create Predicate
strWhere = strWhere & " AND " & "Orders.[CustomerID] = " & Me.Customer & ""
End If

If Not IsNull(Me.Supplier) Then
'Create Predicate
strWhere = strWhere & " AND " & "Orders.[SupplierID] = " & Me.Supplier & ""
End If
Me.Track_All_Orders.Form.Filter = strWhere
Me.Track_All_Orders.Form.FilterOn = True
End Sub

This works great! But I want to use strWhere to Filter the report too.
If I need to open the report, its simple :
Private Sub cmdGenerateReport_Click()
Dim stDocName As String
stDocName = "Statement"
DoCmd.OpenReport stDocName, acPreview, , strWhere
End Sub

In my case I need to apply the filter to the report without the need to open it!
Any suggestions and Help is highly appreciated!

Have a nice weekend,

Nizar

Nizar
01-05-2008, 10:23 AM
I tried these two lines:

Reports![Orders Statement].Filter = Me.strWhere
Reports![Orders Statement].FilterOn = True

However, to compile them the necessity to open the report still remains!!

Thanks in advance for Help,

Best Regards,