wild cards in LIKE using a text parameter

J

jrtmax

I am trying to use a parameter for a query which will define a string of text
to be used in a LIKE comparison.

For example, the code could be stated as:

SELECT tblA.*
FROM tblA
WHERE tblA.text LIKE "*xxx*";

However I would like to start with a parameter section:

PARAMETERS [Control Activity #] Text(255);
SELECT tblA.*
FROM tblA
WHERE tblA.text LIKE "*[Control Activity #]*";

When I try this the parameter supplied is not accurately evaluated.

How do I use the wild card in this case?
 
K

Ken Snell [MVP]

Try this:

PARAMETERS [Control Activity #] Text(255);
SELECT tblA.*
FROM tblA
WHERE tblA.text LIKE "*" & [Control Activity #] & "*";
 
Top