search for 2 parameters

S

Sensay

hello,
how can i serach for records that contan 2 words, for example. search for
records that contains : 'access' and 'query' .
what's the best way for that

thanks in advance.
Sensay
 
K

KARL DEWEY

Use this for your criteria to select one or two --
Like "*" & [Enter word 1] & "*" and Like "*" & [Enter word 2] & "*"

If a second word is not wanted then just press ENTER when prompted.
 
J

John Spencer (MVP)

Two words in the same field? or Two words in different fields.

Two words in the same field is easy.
SELECT *
FROM TableName
WHERE FieldA Like "*" & [Find First Word] & "*" AND
FieldA Like "*" & [Find Second Word] & "*"

Two words somewhere in the entire record is more complex.

If you are doing this in the query grid. Enter
Field: FieldA
Criteria: Like "*" & [Find First Word] & "*" AND Like "*" & [Find Second Word]
& "*"
 
S

Sensay

how can i insert data into these variables [Find First Word] and [Find Second
Word] from a text box in a form ?

sensay

John Spencer (MVP) said:
Two words in the same field? or Two words in different fields.

Two words in the same field is easy.
SELECT *
FROM TableName
WHERE FieldA Like "*" & [Find First Word] & "*" AND
FieldA Like "*" & [Find Second Word] & "*"

Two words somewhere in the entire record is more complex.

If you are doing this in the query grid. Enter
Field: FieldA
Criteria: Like "*" & [Find First Word] & "*" AND Like "*" & [Find Second Word]
& "*"
hello,
how can i serach for records that contan 2 words, for example. search for
records that contains : 'access' and 'query' .
what's the best way for that

thanks in advance.
Sensay
 
D

Douglas J. Steele

Replace those parameters with the names of the textboxes on the form:

SELECT *
FROM TableName
WHERE FieldA Like "*" & Forms!MyForm!TextBox1 & "*" AND
FieldA Like "*" & Forms!MyForm!TextBox2 & "*"

Note that the form must be open for this to work: Access will not open the
form for you if you run the query when the form isn't open.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Sensay said:
how can i insert data into these variables [Find First Word] and [Find
Second
Word] from a text box in a form ?

sensay

John Spencer (MVP) said:
Two words in the same field? or Two words in different fields.

Two words in the same field is easy.
SELECT *
FROM TableName
WHERE FieldA Like "*" & [Find First Word] & "*" AND
FieldA Like "*" & [Find Second Word] & "*"

Two words somewhere in the entire record is more complex.

If you are doing this in the query grid. Enter
Field: FieldA
Criteria: Like "*" & [Find First Word] & "*" AND Like "*" & [Find Second
Word]
& "*"
hello,
how can i serach for records that contan 2 words, for example. search
for
records that contains : 'access' and 'query' .
what's the best way for that

thanks in advance.
Sensay
 
Top