'LIKE' query not working

D

Dennis

In Access 2003, I'm trying to write a query using the Query Designer/SQL
window. Basically, I'm trying to execute a query with "LIKE" in it, with a
prompted value. However, the syntax doesn't seem to work, no matter what
permutations I try.

Example:

SELECT Table1.Field1
FROM Table1
WHERE (((Table1.Field1) Like [Prompt] & '%'));

That doesn't work.

WHERE (((Table1.Field1) Like '[Prompt]%'));

That doesn't work either

Any thoughts on how to construct this LIKE would sure be appreciated.

Thanks a bunch!
 
K

Ken Sheridan

Jet uses the asterisk as the wildcard character:

LIKE [Prompt] & "*"

Ken Sheridan
Stafford, England
 
D

Dennis

Geez. Leave it to me to "over-SQL" my attempt at a solution. That worked
perfectly.

Thanks!



Ken Sheridan said:
Jet uses the asterisk as the wildcard character:

LIKE [Prompt] & "*"

Ken Sheridan
Stafford, England

Dennis said:
In Access 2003, I'm trying to write a query using the Query Designer/SQL
window. Basically, I'm trying to execute a query with "LIKE" in it, with a
prompted value. However, the syntax doesn't seem to work, no matter what
permutations I try.

Example:

SELECT Table1.Field1
FROM Table1
WHERE (((Table1.Field1) Like [Prompt] & '%'));

That doesn't work.

WHERE (((Table1.Field1) Like '[Prompt]%'));

That doesn't work either

Any thoughts on how to construct this LIKE would sure be appreciated.

Thanks a bunch!
 
M

Marshall Barton

Dennis said:
In Access 2003, I'm trying to write a query using the Query Designer/SQL
window. Basically, I'm trying to execute a query with "LIKE" in it, with a
prompted value. However, the syntax doesn't seem to work, no matter what
permutations I try.

Example:

SELECT Table1.Field1
FROM Table1
WHERE (((Table1.Field1) Like [Prompt] & '%'));

That doesn't work.

WHERE (((Table1.Field1) Like '[Prompt]%'));

That doesn't work either

Any thoughts on how to construct this LIKE would sure be appreciated.


WHERE Table1.Field1 Like [Prompt] & '%'
is legal in some versions of SQL (ADO, Ansi92, SQL Server,
etc), but the usual DAO wildcard is * instead of %
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top