Edit

Share via


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

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.