Simple Search? (Oxymoron)

  • Thread starter Thread starter Troy
  • Start date Start date
T

Troy

Hi All,
I'm trying to convence Access to search a table using the
Like Command. I'm using: Like "[search]*" This should
search for occurences of the 'search' yet it returns all
records or no records. It's a description field and I
would like it to find that word or partial word.
Any ideas as to what I'm doing wrong?
Thanks in Advance,
Best,
Troy
 
You might try

Like "*search*"

The square brackets have special meaning to Like -- they allow you to search
for a range of characters, or for a character that otherwise has "special"
meaning to Like (such as an asterisk, which otherwise matches zero or more
of any characters). For example, the expression

Like "[*]*"

will match all values that start with an asterisk.

Since the letters, s, e, a, r, c, and h have no "special" meaning to Like,
so it just interprets them as individual characters. In other words

Like "[search]*"

will match all values that start with s, e, a, r, c, or h.

Check the help for details.
 
Troy said:
Hi All,
I'm trying to convence Access to search a table using the
Like Command. I'm using: Like "[search]*" This should
search for occurences of the 'search' yet it returns all
records or no records. It's a description field and I
would like it to find that word or partial word.
Any ideas as to what I'm doing wrong?
Thanks in Advance,
Best,
Troy

Hi Troy,
i think you use the wrong wildcard, you must take 'search%'

bets regards
dirk
 
If you're trying to search on a parameter value, you must code it like this:

LIKE [Search] & "*"

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
From the help file:

In the Criteria cell for each field you want to use as a
parameter, type an expression with a prompt enclosed in
square brackets. To prompt the user for one or more
characters to search for, and then find records that
begin with or contain the characters the user specifies,
create a parameter query that uses the LIKE operator and
the wildcard symbol (*).

For example, the following statement searches for words
that begin with a specified letter:

LIKE [Enter the first character to search by: ] & "*"

The following statement searches for words that contain
the specified character:

LIKE "*" & [Enter any character to search by: ] & "*"
 
Back
Top