FIX: Compound Filter Condition in ADO2.5 Incorrectly Returns 0 Records (264002)
The information in this article applies to:
- ActiveX Data Objects (ADO) 2.5
This article was previously published under Q264002 SYMPTOMS
Under all prior versions of ActiveX Data Objects (ADO), using a compound filter condition with expressions joined by an AND clause
returned the correct subset of records. In ADO 2.5, there are a number of circumstances where a filter condition incorrectly returns 0 records.
RESOLUTION
This problem has been fixed in MDAC 2.6. For previous versions of MDAC the following workarounds are available:
- Build a local index on the second and subsequent fields in the filter condition. For example, to filter on the expression
FIELD1 = 'Value1' and FIELD2 = 'Value2'
add the following line to your code before the filter condition is applied:
rs.Fields("FIELD2").Properties("Optimize") = True
Concatenate the filter condition to itself with the OR clause. For example, to filter on the expression
FIELD1 = 'Value1' and FIELD2 = 'Value2'
add the lines:
FilterString = "(FIELD1 = 'Value1' and FIELD2 = 'Value2')"
FilterString = FilterString & " OR " & FilterString
rs.Filter = FilterString
If all the filter expressions test equality to a character expression, use LIKE in the filter expression. In place of
FilterString = "FIELD1 = 'Value1' and FIELD2 = 'Value2'
substitute:
FilterString = "FIELD1 LIKE 'Value1%' and FIELD2 LIKE 'Bar%"
- Concatenate the filter condition to itself with the OR clause. For example, to filter on the expression
FIELD1 = 'Value1' and FIELD2 = 'Value2'
add the lines:
FilterString = "(FIELD1 = 'Value1' and FIELD2 = 'Value2')"
FilterString = FilterString & " OR " & FilterString
rs.Filter = FilterString
If all the filter expressions test equality to a character expression, use LIKE in the filter expression. In place of
FilterString = "FIELD1 = 'Value1' and FIELD2 = 'Value2'
substitute:
FilterString = "FIELD1 LIKE 'Value1%' and FIELD2 LIKE 'Bar%"
- If all the filter expressions test equality to a character expression, use LIKE in the filter expression. In place of
FilterString = "FIELD1 = 'Value1' and FIELD2 = 'Value2'
substitute:
FilterString = "FIELD1 LIKE 'Value1%' and FIELD2 LIKE 'Bar%"
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 10/15/2002 |
---|
Keywords: | kbBug kbDSupport kbMDAC260fix KB264002 |
---|
|