Queries

  • Thread starter Thread starter paice
  • Start date Start date
P

paice

I am trying to create a form where the user can type in
something to search for and the query pulls up everything
containing the work they typed in. My query currently
looks like this:
SELECT [ISSUE/PROBLEM].[ISSUE/PROBLEM NUMBER],
[ISSUE/PROBLEM].[DATE RECEIVED], [ISSUE/PROBLEM].CATEGORY,
[ISSUE/PROBLEM].SUMMARY
FROM [ISSUE/PROBLEM]
WHERE (((forms![problem list]![search for]) Like
([ISSUE/PROBLEM].SUMMARY)))
ORDER BY [ISSUE/PROBLEM].[DATE RECEIVED];
The only thing it is pulling up is the ones that have the
exact work in the subject. For instance, I have two
with "Test" as the summary, it will pull up test because
that is all that is in the summary.
Is there any way I can have it pull up all the items
containing the word, insead of exact?
Thanks in advance
 
The only thing it is pulling up is the ones that have the
exact work in the subject. For instance, I have two
with "Test" as the summary, it will pull up test because
that is all that is in the summary.
Is there any way I can have it pull up all the items
containing the word, insead of exact?

You've got two problems: the LIKE operator's arguments are backwards,
and you're not using any wildcards. LIKE without any wildcard
characters - * for any string of characters, ? for any single
character, # for any numeric digit, etc. - works just like = and
assumes you only want perfect matches.

Try changing the WHERE clause to

WHERE [ISSUE/PROBLEM].SUMMARY LIKE "*" & forms![problem list]![search
for] & "*"

(I discarded the extra parentheses that the query grid puts in for no
apparent reason).

This will take a user input of PBKAC (Problem Between Keyboard And
Chair) and generate a criterion

LIKE *PBKAC*

which will find all such problems.
 
Back
Top