Search multiple words in field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi - I've been try to run a Query by form command and it seems to work fine
but it only searches the first word in the field. Is it possible to have it
check all words as it would in a regular search. I was looking at KB Article
209645 and it gives some examples but I have had no luck. The syntax for my
query presently is: Like [Forms]![QBF_Form]![WhatEmployee] & "*". If I run
this and type in just G it will only give me the results for the data in the
field that beging with G. I'd like to have all occurances. I referenced the
Northwind example.
 
Hi - I've been try to run a Query by form command and it seems to work fine
but it only searches the first word in the field. Is it possible to have it
check all words as it would in a regular search. I was looking at KB Article
209645 and it gives some examples but I have had no luck. The syntax for my
query presently is: Like [Forms]![QBF_Form]![WhatEmployee] & "*". If I run
this and type in just G it will only give me the results for the data in the
field that beging with G. I'd like to have all occurances. I referenced the
Northwind example.

Place the wild card at the beginning as well as at the end.

Like "*" & [Forms]![QBF_Form]![WhatEmployee] & "*"
 
In a query with criteria, when there are more than one criteria in the same
row, that is an AND condition meaning the records must meet each criteria.
Conversely, you can put criteria in different rows, that is an OR condition
meaning the records must meet one or the other criteria (or both). You can
use the OR concept to achieve what you want. On QBF_Form, add a new textbox
named WhatOtherEmployee. In your query, in the field you are setting
criteria for, you have Like [Forms]![QBF_Form]![WhatEmployee] & "*" as
criteria in the first row. Paste the following into the second criteria row:
Like [Forms]![QBF_Form]![WhatOtherEmployee] & "*"
Now you can enter G in the WhatEmployee textbox and say R in the
WhatOtherEmployee textbox and the query will return all employees that begin
with G or R. You can extend this to more than two rows in your query by
adding more textboxes to QBF_Form and criteria to more rows in your query.
 
Back
Top