Apply a filter clause to a table, form, or report.
Syntax DoCmd.ApplyFilter(FilterName, WhereCondition, ControlName) Key FilterName The 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. (String) WhereCondition A valid SQL WHERE clause without the word WHERE. ControlName The name of the control that corresponds to the subform or subreport to be filtered. If empty, the current object is filtered.
At least one of the two ApplyFilter method arguments must be supplied. If you enter a value for both arguments, the WhereCondition argument is applied to the filter.
The ApplyFilter action can be applied to a form or a report to restrict or sort the records displayed.
When a form or report is saved, Access saves any filter/WHERE condition currently defined in that object, but will not apply the filter automatically the next time the form is opened (although it will automatically apply any sort you applied to the object before it was saved).
The maximum length of the WhereCondition argument is 32,768 characters.
DoCmd.ApplyFilter , "LastName = 'King'"
“To be without some of the things you want is an indispensable part of happiness” ~ Bertrand Russell
.SetFilter - Apply a filter to the records being displayed.
.ShowAllRecords - Remove any applied filter.