PC Review


Reply
Thread Tools Rate Thread

Multiple Criteria

 
 
=?Utf-8?B?TWF4?=
Guest
Posts: n/a
 
      16th Mar 2006
Using a Findfirst to locate a record in a linked table. How do I set up the
criteria for three variables that are strings and one variable that is a
number:

I need the grammer of quotes, single quotes, and &s to complete this line of
code: rst.findfirst Job=mStr1 and Name=mStr2 and Place=mStr3 and ID=mNum1

Tried the KB article - same examples that have been in use since Access7.0 -
no help there. Thanks in advance.
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      17th Mar 2006
Concatenate the values from your variables into the string you want to use
for FindFirst.

Delimit the values for the Text fields (but not the Number field) with
quotes.

This kind of thing:
Dim strWhere As String
strWhere = "(Job = """ & mStr1 & """) AND (Name = """ & mStr2 & _
""") AND (Place = """ & mStr3 & """) AND (ID = " & mNum1 & ")"
Debug.Print strWhere
rst.FindFirst strWhere

The Debug.Print dumps the string to the Immediate Window (Ctrl+G). You can
then see if it looks right. It must look just like the WHERE clause of a
query.

(Note that a field called Name is going to give you problems in many
contexts. Nearly everything in Access has a Name property: tables, fields,
forms, reports, controls, ..., and at some point Access will thing you mean
the name of something else instead of the contents of the field.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Max" <(E-Mail Removed)> wrote in message
news:6E3852AC-CADB-4F20-9C6C-(E-Mail Removed)...
> Using a Findfirst to locate a record in a linked table. How do I set up
> the
> criteria for three variables that are strings and one variable that is a
> number:
>
> I need the grammer of quotes, single quotes, and &s to complete this line
> of
> code: rst.findfirst Job=mStr1 and Name=mStr2 and Place=mStr3 and ID=mNum1
>
> Tried the KB article - same examples that have been in use since
> Access7.0 -
> no help there. Thanks in advance.



 
Reply With Quote
 
=?Utf-8?B?TWF4?=
Guest
Posts: n/a
 
      17th Mar 2006
Thanks a million!!


"Max" wrote:

> Using a Findfirst to locate a record in a linked table. How do I set up the
> criteria for three variables that are strings and one variable that is a
> number:
>
> I need the grammer of quotes, single quotes, and &s to complete this line of
> code: rst.findfirst Job=mStr1 and Name=mStr2 and Place=mStr3 and ID=mNum1
>
> Tried the KB article - same examples that have been in use since Access7.0 -
> no help there. Thanks in advance.

 
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
How to stop Access re-arranging query criteria onto multiple criteria lines for OR condition Chrisso Microsoft Access 3 9th Nov 2007 12:50 PM
match multiple criteria ina range from multiple criteria multiplet =?Utf-8?B?Ukc=?= Microsoft Excel Worksheet Functions 7 28th Sep 2007 05:21 AM
RE: match multiple criteria ina range from multiple criteria multiplet =?Utf-8?B?Ukc=?= Microsoft Excel Worksheet Functions 0 27th Sep 2007 06:24 AM
Counting Cells with multiple criteria.One criteria supporting wild =?Utf-8?B?QXpoYXIgQXJhaW4=?= Microsoft Excel Worksheet Functions 1 12th Jan 2005 09:33 AM
Counting Cells with multiple criteria.One criteria supporting wild =?Utf-8?B?QXpoYXIgU2FsZWVt?= Microsoft Excel Worksheet Functions 0 12th Jan 2005 08:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:25 PM.