[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

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??
0
jeffstatt
Asked:
jeffstatt
  • 4
  • 3
  • 3
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
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'")
0
 
jeffstattAuthor Commented:
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.
0
 
gencrossCommented:
Good answer emoreau.  That is the only way I know to do it also.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
gencrossCommented:
What about using a filter?

Instead of:
rs.find "Purchaser = 'Acme' AND InvoiceNo = 'X34FF'",,adSearchForward

use:

rs.Filter = "Purchaser = 'Acme' AND InvoiceNo = 'X34FF'"

When you are finished with the filter:

rs.Filter = adFilterNone

This will allow only the the records in the criteria to be viewed in the rs.

Hope this helps
0
 
Éric MoreauSenior .Net ConsultantCommented:
There is another way: use the Filter property.

0
 
Éric MoreauSenior .Net ConsultantCommented:
You beat me!
0
 
jeffstattAuthor Commented:
That'll work as an exceptable substitute.  I forgot completely about .Filter! DUH!

Thanks!
0
 
gencrossCommented:
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 :)
0
 
jeffstattAuthor Commented:
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 :)
0
 
jeffstattAuthor Commented:
How 'bout B+ ?

;)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now