SET FILTER Command

Specifies that records in the current table must meet certain conditions to be accessible.

SET FILTER TO [lExpression] [IN nWorkArea | cTableAlias]

Parameters

  • lExpression
    Specifies the condition that records must satisfy.

    If the current table is indexed on a field or fields specified in lExpression, Rushmore Query Optimization technology can optimize queries based on the field or fields.

  • IN nWorkArea| cTableAlias
    Specifies the work area or table alias that is affected by the SET FILTER command. Use this clause to specify a work area or a table outside the current work area.

Remarks

You can set a separate filter for every open table. In most cases, once you issue SET FILTER, you can retrieve only the records in the table that satisfy the condition specified by the logical expression lExpression. When the applied scope clause references records in relative terms, all commands that allow a scope clause will respect the SET FILTER condition. However, any command that uses a stated or implied scope of RECORD nRecordNumber, including GOTO, REPLACE, and others, will not respect the filter. Such commands always act on the specified record, provided the record exists. This is true even if the filter excludes that record. Note, however, that the GOTO TOP/BOTTOM command does respect the filter condition.

The condition specified by SET FILTER is not evaluated until the record pointer is moved in the table.

When you issue SET FILTER TO without using lExpression, you will turn off the filter for the current table.

SELECT – SQL does not respect the current filter condition.

Note

When you use SET FILTER to filter data in a grid, use the SET KEY command to increase grid performance.

When you issue a SET FILTER command, Visual FoxPro internally converts the filter expression to a preferred format. If your original filter expression includes shortened commands (for example, UPPE instead of UPPER), the return values from SET("FILTER") and FILTER( ) will not be an exact match to your original filter expression. You can use NORMALIZE( ) with the filter expression. This will return it in a form that matches the output of SET("FILTER") and FILTER( )."

See Also

Tasks

How to: Create and Use Table Aliases

Reference

FILTER( ) Function

SELECT - SQL Command

SET Command Overview

NORMALIZE( ) Function

Other Resources

Commands (Visual FoxPro)

Language Reference (Visual FoxPro)