Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Find Method (ADO) need boolean criteria

Posted on 2002-06-19
10
Medium Priority
?
232 Views
Last Modified: 2010-05-02
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
Comment
Question by:jeffstatt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7093467
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
 

Author Comment

by:jeffstatt
ID: 7093478
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
 
LVL 4

Expert Comment

by:gencross
ID: 7093481
Good answer emoreau.  That is the only way I know to do it also.
0
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.

 
LVL 4

Accepted Solution

by:
gencross earned 900 total points
ID: 7093500
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
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7093505
There is another way: use the Filter property.

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7093507
You beat me!
0
 

Author Comment

by:jeffstatt
ID: 7093514
That'll work as an exceptable substitute.  I forgot completely about .Filter! DUH!

Thanks!
0
 
LVL 4

Expert Comment

by:gencross
ID: 7093538
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
 

Author Comment

by:jeffstatt
ID: 7093544
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
 

Author Comment

by:jeffstatt
ID: 7093546
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question