Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting variables in a MS Access Query which uses Like

Status
Not open for further replies.

JuneHomer

Programmer
Aug 6, 2001
4
GB
I have the following SQL statement in Access which I want to amend to accept a variable instead of June:-

SELECT *
FROM Staff
WHERE Name LIKE "June*";

I have tried:-
SELECT *
FROM Staff
WHERE Name LIKE "[@name]*";

which does not work. I'm sure this is a straight forward question. Any help appreciated.
 
try this
select * from staff where name
like "*" & forms!form1!text1 & "*"

where form1 is the name of a form with a text box called text1

Nick
 
Thanks Nick for this, but I am wanting to pass the variable via an ASP and therefore do not have any forms.
 
Hello JuneHomer,

Pardon my ignorance, but what is an ASP.

I know you could do it like this:

SELECT * FROM Staff WHERE Name LIKE [Month];

This will prompt you for a name to look for.

rnpIII
 

Could you post the ASP code that builds and submits your query? That will help me formulate the correct answer.

Thanks, Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top