Link to home
Start Free TrialLog in
Avatar of jeffstatt
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'",,adSearchForward

Same result..


Maybe it can't be done??
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

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'")
Avatar of jeffstatt
jeffstatt

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.
Good answer emoreau.  That is the only way I know to do it also.
ASKER CERTIFIED SOLUTION
Avatar of gencross
gencross

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is another way: use the Filter property.

You beat me!
That'll work as an exceptable substitute.  I forgot completely about .Filter! DUH!

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 :)
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 :)
How 'bout B+ ?

;)