The ApplyFilter method carries out the ApplyFilter action in Visual Basic. For more information on how the action and its arguments work, see the action topic.
Syntax
DoCmd.ApplyFilter [filtername][, wherecondition][, filtertype]
The ApplyFilter method has the following arguments.
Argument | Description |
---|---|
filtername | A string expression that's the valid name of a filter or query in the current database. |
Note When using this method to apply a server filter, the filtername argument must be blank. | |
wherecondition | A string expression that's a valid SQL WHERE clause without the word WHERE. |
filtertype | One of the following intrinsic constants: |
acFilterNormal (default) acServerFilter |
The filter and WHERE condition you apply become the setting of the form's or report's Filter or ServerFilter property.
Remarks
You must include at least one of the two ApplyFilter method arguments. If you enter a value for both arguments, the wherecondition argument is applied to the filter.
The maximum length of the wherecondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).
If you specify the wherecondition argument and leave the filtername argument blank, you must include the filtername argument's comma.