PC Review


Reply
Thread Tools Rate Thread

ADO Find method

 
 
Keith
Guest
Posts: n/a
 
      28th Jan 2010
I would like to know if there is a way to use the ADO Find method to find one
of several values for a single column. See the following example:

rstOpenJobProcess.Find "[proc#] = '940' or '941'"

I would like to search for proc# '940' or '941'. I want to avoid using a
like statement in the criteria (such as [proc#] Like '94*') because I may use
'942' for something else in the future that I would not want to search for.
Is there a way to use the Find method in this way? Alternatively, is there a
clever workaround?

Thanks,

Keith
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      28th Jan 2010
"Keith" <(E-Mail Removed)> wrote in message
news:CF416F20-AEA6-4774-920E-(E-Mail Removed)...
>I would like to know if there is a way to use the ADO Find method to find
>one
> of several values for a single column. See the following example:
>
> rstOpenJobProcess.Find "[proc#] = '940' or '941'"
>
> I would like to search for proc# '940' or '941'. I want to avoid using a
> like statement in the criteria (such as [proc#] Like '94*') because I may
> use
> '942' for something else in the future that I would not want to search
> for.
> Is there a way to use the Find method in this way? Alternatively, is
> there a
> clever workaround?



Try this:

rstOpenJobProcess.Find "[proc#] In ('940', '941')"

That's assuming that [proc#] is a text field, as your original code
suggests.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
Keith
Guest
Posts: n/a
 
      28th Jan 2010
Dirk,

Thanks so much for the response. This looks like exactly what I'm asking
for. Unfortunately, when I use this code, I get the following error message:

"Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another."

[proc#] is a text field as you assumed, so that's not the issue.

I have figured out a workaround, basically using the find method twice and
determining which result is what I want. It's clunky, but it will work. If
you have any other thoughts, please let me know. I could see this coming up
again in the future.

Thanks again,

Keith


"Dirk Goldgar" wrote:

> "Keith" <(E-Mail Removed)> wrote in message
> news:CF416F20-AEA6-4774-920E-(E-Mail Removed)...
> >I would like to know if there is a way to use the ADO Find method to find
> >one
> > of several values for a single column. See the following example:
> >
> > rstOpenJobProcess.Find "[proc#] = '940' or '941'"
> >
> > I would like to search for proc# '940' or '941'. I want to avoid using a
> > like statement in the criteria (such as [proc#] Like '94*') because I may
> > use
> > '942' for something else in the future that I would not want to search
> > for.
> > Is there a way to use the Find method in this way? Alternatively, is
> > there a
> > clever workaround?

>
>
> Try this:
>
> rstOpenJobProcess.Find "[proc#] In ('940', '941')"
>
> That's assuming that [proc#] is a text field, as your original code
> suggests.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>

 
Reply With Quote
 
vanderghast
Guest
Posts: n/a
 
      28th Jan 2010
ADO recordset Find method support only one test. Use successive test on
successive clones as workaround (http://support.microsoft.com/kb/195222) or
use an SQL query which will pump the primary key value for your complex
criteria and feed the ADO method with a test on that later.


Vanderghast, Access MVP


"Keith" <(E-Mail Removed)> wrote in message
news:CF416F20-AEA6-4774-920E-(E-Mail Removed)...
>I would like to know if there is a way to use the ADO Find method to find
>one
> of several values for a single column. See the following example:
>
> rstOpenJobProcess.Find "[proc#] = '940' or '941'"
>
> I would like to search for proc# '940' or '941'. I want to avoid using a
> like statement in the criteria (such as [proc#] Like '94*') because I may
> use
> '942' for something else in the future that I would not want to search
> for.
> Is there a way to use the Find method in this way? Alternatively, is
> there a
> clever workaround?
>
> Thanks,
>
> Keith


 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      28th Jan 2010
"Keith" <(E-Mail Removed)> wrote in message
news:13907BE0-3416-4DC2-9310-(E-Mail Removed)...
> Dirk,
>
> Thanks so much for the response. This looks like exactly what I'm asking
> for. Unfortunately, when I use this code, I get the following error
> message:
>
> "Arguments are of the wrong type, are out of acceptable range, or are in
> conflict with one another."


Drat! I'd hoped that phrasing the criterion as an In() expression would get
past ADO's restriction on the Find method. But no, it only allows certain
comparison operators and a single field and value to be tested.

> I have figured out a workaround, basically using the find method twice and
> determining which result is what I want. It's clunky, but it will work.
> If
> you have any other thoughts, please let me know. I could see this coming
> up
> again in the future.


Vanderghast has pointed you to a KB article that may give you some
alternatives.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xls vba find method to find row that contains the current date =?Utf-8?B?UkNyYW5zdG9u?= Microsoft Excel Programming 5 28th Mar 2007 03:59 PM
date find using find method x taol Microsoft Excel Programming 2 22nd Dec 2005 09:51 AM
Using variables to make a date and using find method to find that. =?Utf-8?B?S3lXaWxkZQ==?= Microsoft Excel Programming 2 21st Apr 2005 09:43 PM
Find method nk Microsoft Excel Programming 2 16th Apr 2005 01:50 PM
help with find method grinning_crow Microsoft Excel Programming 2 25th Mar 2004 01:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:28 AM.