DoCmd.ApplyFilter (Access)
The ApplyFilter method carries out the ApplyFilter action in Visual Basic.
You can use the ApplyFilter action to apply a filter, a query, or an SQL WHERE clause to a table, form, or report to restrict or sort the records in the table or the records from the underlying table or query of the form or report. For reports, you can use this action only in a macro specified by the report's OnOpen event property. You can use this action to apply an SQL WHERE clause only when applying a server filter. A server filter cannot be applied to a stored procedure's record source.
ApplyFilter (FilterName, WhereCondition, ControlName)
DoCmd.ApplyFilter , "LastName = 'King'"
Arguments
Optional arguments
The following arguments are optional
FilterName (String) - A string expression that is the valid name of a filter or query in the current database. When using this method to apply a server filter, the FilterName argument must be blank.
WhereCondition (String) - A string expression that is a valid SQL WHERE clause without the word WHERE.
ControlName - String