How to open a parameter query from code

J

jmonty

See the experts:

http://www.mvps.org/access/queries/qry0003.htm

-----Original Message-----
Hello;
I have a parameter query named "OpenQRY" having 1 parameter "dIDParam" with
this SQL property:
PARAMETERS [dIDParam] Long;
SELECT Name
FROM DrugsTBL
WHERE (((dID)=[dIDParam]));

And I use this code to open it:
Set DB = DBEngine(0)(0)
Set Qdf = DB.QueryDefs("OpenQry")
Qdf.Parameters!dIDParam= 5
Now when i try to open this query using
DoCmd.OpenQuery "OpenQRY" ,it askes
 
M

Mota

What i have wrote is exactly the code written in this link.But it doesnt
work and Run-Time error 3061 occures(Too few parameters.Expected 1)
I hope u test it urself.Any suggestion?
Thank you for ur attention.

jmonty said:
See the experts:

http://www.mvps.org/access/queries/qry0003.htm

-----Original Message-----
Hello;
I have a parameter query named "OpenQRY" having 1 parameter "dIDParam" with
this SQL property:
PARAMETERS [dIDParam] Long;
SELECT Name
FROM DrugsTBL
WHERE (((dID)=[dIDParam]));

And I use this code to open it:
Set DB = DBEngine(0)(0)
Set Qdf = DB.QueryDefs("OpenQry")
Qdf.Parameters!dIDParam= 5
Now when i try to open this query using
DoCmd.OpenQuery "OpenQRY" ,it askes
dIDParam,although i set it already in my code.it seems the line
Qdf.Parameters!dIDParam is ignored by Access.Whats wrong here?How can i set
a parameter of a stored query thru code?
Thank you for ur help.


.
 

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