Searching

  • Thread starter Thread starter Shannon
  • Start date Start date
S

Shannon

What is the SQL statement for queries by keywords?
such as searching for records of last names begin w/
letter N
 
Below is just an example of what the user might enter.
What would the code be if you don't know what the user
might enter and search upon what he/she entered.
 
I have to make some assumptions here. If the assumptions
are false, let me know.
1. The user is being prompted for input.
2. If the user always inputs the first characters of the
sought string, the code would be (where the text in square
brackets is the user on-screen prompt; you can put
anything you want here):
Like [Enter keyword] & "*"
3. If the user can input any part of the sought string,
the code would be:
Like "*" & [Enter keyword] & "*"

The first case is more limiting, only returning records
that start with the keyword; the second case is more
flexible but will return all records that have the keyword
anywhere in the field. Thus, if set up as in the second
case, the user inputs N, records like 'Norris' and 'Snow'
will both be returned. An input of NO will return both,
as well, but would only return Norris if set up as in the
first case - a leading NO.

The user can input as much or as little of the keyword as
he wants, as long as the keyword represents consecutive
characters.

Hope this helps.
 
Back
Top