?
Solved

Find Method (ADO) need boolean criteria

Posted on 2002-06-19
10
Medium Priority
?
230 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

800 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