The information in this article applies to:
SYMPTOMS
Comparing two fields in the criteria string of the ADO Filter property, (for example: The criteria string is made up of clauses in the form: " FieldName Operator FieldName ") generates the following error:
CAUSE
This functionality cannot be accomplished with current versions of ADO. The criteria syntax of the ADO Filter property is defined as follows: " FieldName Operator 'Literal_Value' "The 'Literal_Value' data type could be string, number, or date. You cannot use the preceding expression to compare two fields. Attempting to do so raises error 3001. RESOLUTION
One workaround is to have several expressions joined by Boolean operators as the Filter criteria. You can only use this if the the values of compared fields are known to the developer. This way the developer can come up with a formula for the criteria string that meets the required results. For example:
If the developer does not know the values for Field1 and Field2, then the developer has to use either a custom Filter routine (within the client application) or a stored procedure (on the server side) to accomplish the functionality dynamically. You can use control-flow statements within the custom Filter routine (or the stored procedure) to perform the necessary Field comparisons and generate the expected results. This article provides a demonstration for such a routine in the "MORE INFORMATION" section of this article. WARNING: The workaround, provided in the MORE INFORMATION section, is only given for illustration purpose, without any warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. STATUSThis behavior is by design. MORE INFORMATION
The ADO Help documentation states the following for the Filter method's criteria expression -- under Remarks:
The criteria string is made up of clauses in the form FieldName - Operator - Value (for example, "LastName = 'Smith'"). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") or OR (for example, "LastName = 'Smith' OR LastName = 'Jones'").It also states the following guidelines for the Criteria Value: Value is the value with which you will compare the field values (for example, 'Smith', #8/24/95#, 12.345 or $50.00). Use single quotes with strings and pound signs (#) with dates. For numbers, you can use decimal points, dollar signs, and scientific notation. If Operator is LIKE, Value can use wildcards. Only the asterisk (*) and percent sign (%) wild cards are allowed, and they must be the last character in the string. Value cannot be Null.Steps to Reproduce Behavior ===========================
REFERENCES
For more information, please refer to the ADO Help documentation. Q195222 PRB: ADO Find Method Only Supports One Criteria(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Ammar Abuthuraya, Microsoft Corporation. Additional query words: kbADO kbADO200 kbVBp kbcode
Keywords : kbADO kbADO200 kbDatabase kbVBp kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2 |
Last Reviewed: November 17, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |