Article ID: 216873 - View products that this article applies to.
This article was previously published under Q216873
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:
Runtime error '3001':
The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another.
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.
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.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
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
Press F5 to run the project, and error 3001 occurs.
For more information, please refer to the ADO Help documentation.
For additional information, please see the following article in the Microsoft Knowledge Base:
(https://support.microsoft.com/kb/195222/EN-US/ )PRB: ADO Find Method Only Supports One Criteria
Article ID: 216873 - Last Review: August 24, 2001 - Revision: 1.0
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.