FilterFilter*
*Contents  *Index  *Topic Contents
*Previous Topic: FieldDelim
*Next Topic: Language

Filter

Specifies how the data will be filtered.

Syntax

dataobj.object.Filter = sValue

sValueString expression containing one or more columns and associated criteria. By default, this is set to the empty string (that is, no filtering occurs and all rows are displayed). An invalid expression will cause all rows to be returned. If there is no header line that names the columns, they are given default names of Column1, Column2, Column3, and so on. The special wildcard character, *, can be used to match any character.

Filter restricts the data displayed to the user. It can be set in the <OBJECT> tag description to cause initial filtering, or the browser script language can set it and it will take effect when the Reset method is called. The data is fetched only once, so this is an efficient way of displaying the same data many different ways.

The following <OBJECT> tag description will cause address book data to be filtered so that only entries with phone numbers will be displayed.

<PARAM NAME=Filter VALUE="PhoneNum <> ''">

You could use the wildcard character to match all phone numbers starting with 9 with:

<PARAM NAME=Filter VALUE="PhoneNum <> '9*'">

A more complex filter could be:

<PARAM NAME=Filter VALUE="(Quantity > 10 & color = 'lime') | 
    Quantity < 5"

This code would find rows with a quantity greater than 10 that are lime colored combined with all rows that have a quantity less than five.

The exact syntax support by filter is defined below. In essence, any arbitrary expression using the usual relational operators is allowed, including comparisons between fields. AND (&) and OR (|) operators have equal precedence and thus must be surrounded by parenthesis if combined.

Complex ::== Simple
 ::== Simple '&' Simple [ '&' Simple ... ]
 ::== Simple '|' Simple [ '|' Simple ... ]
Simple ::== '(' Complex ')'
 ::== Atom Relop Atom
Relop ::== '=' | '>' | '>=' | '<' | '<=' | '<>'
Atom ::== Characters up to a (, ), >, <, =, & or |

If an atom is recognizable as a field name, it is treated as a field name. Otherwise, it's treated as a value. Quotes (") are processed and force the atom to be treated as a value. Escape characters (\) are processed and allow the use of special characters within a field name. It is illegal to attempt a comparison of two columns with different types.

The definition of 'Complex' expressly forbids mixing logical ANDs and ORs (& and |) unless parentheses are used to clarify the query. The following is illegal:

field1 > 10 & field3 = "lime" | field4 < 5

But the following is allowed:

(field1 > 10 & field3 = "lime") | field4 < 5

See also Reset, Sort, UseHeader


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.