The Filter Property

This property allows you to filter an open recordset so that only records that meet the specified condition are visible. The records that cannot be seen are not deleted, removed, or changed in any way, but are simply hidden from normal recordset operations. This property can be set to a string that specifies the filter you want to place on the records, or to one of the FilterGroupEnum constants.

You can set multiple filters, and the records exposed by the filtered recordset will be only those records that meet all of the conditions. To remove the filter from the recordset, set the Filter property to an empty string or the adFilterNone constant. The following code sample demonstrates filtering a recordset so that it displays only company names that begin with the letter B. Note that the use of wildcards is supported in a filter string:

rsData.Filter = "Company LIKE 'B*'"

You can use the logical AND, OR, and NOT operators to set additional Filter property values:

rsData.Filter = "Company LIKE 'B*' AND [Country/Region] = 'USA'"

0 0

Post a comment