Solved

Find Method (ADO) need boolean criteria

Posted on 2002-06-19
10
226 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
gencross earned 300 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

730 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