Filter SubForm and Report

Nizar

Registered User.
Local time
Today, 10:11
Joined
Oct 21, 2007
Messages
41
Hello everyone,

I'm trying to filter a report based on previous filter of a subform.
I use this Code to Filter the subform
Code:
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 :
Code:
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
 
I tried these two lines:

Code:
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,
 

Users who are viewing this thread

Back
Top Bottom