Filter Property

   

Sets or returns a value that determines the records included in a subsequently opened CdbRecordset object (Microsoft Jet workspaces only).

Syntax

CStringGetFilter(VOID);

VOIDSetFilter(LPCTSTR pstr );

Parameters

Type Argument Description
LPCTSTR pstr A pointer to a string that contains the WHERE clause of an SQL statement without the reserved word WHERE.

Remarks

Use the Filter property to apply a filter to a dynaset-, snapshot-, or forward-only–type CdbRecordset object.

You can use the Filter property to restrict the records returned from an existing object when a new CdbRecordset object is opened based on an existing CdbRecordset object.

In many cases, it's faster to open a new CdbRecordset object by using an SQL statement that includes a WHERE clause.

Use the U.S. date format (month-day-year) when you filter fields containing dates, even if you're not using the U.S. version of the Microsoft Jet database engine (in which case you must assemble any dates by concatenating strings, for example, CString strFilter = strMonth + "-" + strDay + "-" + strYear;). Otherwise, the data may not be filtered as you expect.

If you set the property to a string concatenated with a non-integer value, and the system parameters specify a non-U.S. decimal character such as a comma (for example, CString strFilter = "PRICE > " + strPrice and strPrice = 125,50), an error occurs when you try to open the next CdbRecordset. This is because during concatenation, the number will be converted to a string using your system's default decimal character, and Microsoft Jet SQL only accepts U.S. decimal characters.