Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sorry for such a silly question. I'm trying to figure out how to write a query in access 2003 similar to the: LIKE '%'+ @parameter +'%'

in my test table...i have a record for Anthony Gwynn. In SQL, with the aforementioned LIKE query, I can type in Ant for the first name parameter and the record for Anthony Gwynn would pop up.

so far i've tried (in design view)

LIKE []
LIKE [*]
LIKE [?*]

but so far none of these have produced any results. at least it's asking me for a parameter :P
Posted

Try parametrized query:
SQL
PARAMETERS [inputtext] CHAR;
SELECT *
FROM TableName
WHERE FieldName Like [inputtext]


For further information, please see:
PARAMETERS Declaration (Microsoft Access SQL)[^]
Using parameters with queries and reports[^]
Tips and Techniques for Queries in Access 2007[^]
 
Share this answer
 
figured the answer. sorry for such a silly question.

sql: LIKE '%'+ @parameter +'%'

access: LIKE "*"& [most people seem to tyep in a prompt here:] &"*"

notes:
in the square brackets, do not use a column header name and do not forget the colon inside the bracket. seem like that's important.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900