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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameter to query

Status
Not open for further replies.

ShinyPen

MIS
Nov 6, 2002
10
0
0
GB
I can't seem to find an answer for this anywhere. I'm sure it must be simple.

I have a query called say "Query1". It consists of the following:

------------------------------
PARAMETERS [enter surname] Text;
SELECT tblPERSON.SURNAME
FROM tblPERSON
WHERE tblPERSON.SURNAME=[enter surname];
------------------------------

I want to be able to call "Query1" via vba code.
i.e. "docmd.openquery QUERY1 etc". I also want to be able to automatically pass the value "Smith" into the parameter [enter surname]. Can anybody help please!

p.s. I don't want to hard code frmname.control into the query.

Thanks.
 
Take a look at the Parameters collection of the DAO.QueryDef object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top