Share via


How to: Filter a Report Using a Form's Filter

The following example illustrates how to open a report based on the filtered contents of a form. To do this, specify the form's Filter property as the value of the OpenReport method's WhereCondition argument.

Private Sub cmdOpenReport_Click() 
    If Me.Filter = "" Then 
        MsgBox "Apply a filter to the form first." 
    Else 
        DoCmd.OpenReport "rptCustomers", acViewReport, , Me.Filter 
    End If 
End Sub