jeffstatt
asked on
Find Method (ADO) need boolean criteria
Is it possible to use a boolean expression in the criteria of the .Find method on an ADO recordset?
For instance:
rs.find "Purchaser = 'Acme' AND InvoiceNo = 'X34FF'",,adSearchForward
(this results in syntax error 3001 - argument of the wrong type blah blah blah)
I also tried:
rs.find "Purchaser & InvoiceNo = 'AcmeX34FF'",,adSearchForw ard
Same result..
Maybe it can't be done??
For instance:
rs.find "Purchaser = 'Acme' AND InvoiceNo = 'X34FF'",,adSearchForward
(this results in syntax error 3001 - argument of the wrong type blah blah blah)
I also tried:
rs.find "Purchaser & InvoiceNo = 'AcmeX34FF'",,adSearchForw
Same result..
Maybe it can't be done??
when you open your recordset, you need to concatenate your purchaser and invoice number (select *, purchaser + invoiceno as NewField FROM ...) and use this field in your find( rs.find "NewField = 'AcmeX34FF'")
ASKER
The problem is that I am pulling the recordset directly from an XML document (I do not open it using sql) so I don't have the option of concatenating the field names.
I'm not against having the XML provider send me a concatenated field, but I'd like to exhaust this question first.
I'm not against having the XML provider send me a concatenated field, but I'd like to exhaust this question first.
Good answer emoreau. That is the only way I know to do it also.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is another way: use the Filter property.
You beat me!
ASKER
That'll work as an exceptable substitute. I forgot completely about .Filter! DUH!
Thanks!
Thanks!
I'm glad that solved your problem, but why the grade B? Your question was answered correctly.
<<Is it possible to use a boolean expression in the criteria of the .Find method on an ADO recordset?
Both emoreau and myself said it couldn't be done the way you wanted it. Then we both gave another good solution (I beat him by about five seconds:))
In the future I would think an answer like this would deserve an A :)
<<Is it possible to use a boolean expression in the criteria of the .Find method on an ADO recordset?
Both emoreau and myself said it couldn't be done the way you wanted it. Then we both gave another good solution (I beat him by about five seconds:))
In the future I would think an answer like this would deserve an A :)
ASKER
Because the question was Can the .Find method be done with a boolean expression in the criteria
not
Is there an alternative?
Besides you got 300 points for a relatively easy answer :)
not
Is there an alternative?
Besides you got 300 points for a relatively easy answer :)
ASKER
How 'bout B+ ?
;)
;)