Apply a filter to a table, form, or report. (Access 2010 and above)
Syntax DoCmd.SetFilter(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 SetFilter method arguments must be supplied. If you enter a value for both arguments, the WhereCondition argument is applied to the filter.
The SetFilter 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.
Displays only records that begin with "SS64"
DoCmd.SetFilter WhereCondition:="[Product Code] Like ""SS64*"""
“To be without some of the things you want is an indispensable part of happiness” ~ Bertrand Russell
.ApplyFilter - Apply a filter to the records being displayed.
.ShowAllRecords - Remove any applied filter.