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

Parameters in Query 1

Status
Not open for further replies.

Crookshanks

Technical User
May 18, 2004
296
NL
Good afternoon,

I have created a query with a parameter to filter te results and reduce the number of records it returns.

set qrTxn = db.openrecordset("qry_Transactions") now gives a error of "Two few parameters. Expected 1"

Q: What is the correct syntax (method?) to supply the requested parameter. De parameter is a txtbox on a form ( Forms![TransactionDeletion]![txtFilter].

Any help appreciated. Thanks in advance.

 
First, ensure the form is open, then you'll probably need to inform VB of the parameter, I think this should work:

[tt]dim rs as dao.recordset
dim qd as dao.querydef
dim pr as dao.parameter
set qd=currentdb.querydefs("qry_Transactions")
for each pr in qd.parameters
pr.value=eval(pr.name)
next pr
set rs=qd.openrecordset()[/tt]

Roy-Vidar
 
Thanks. You're code seems to work.
But I cannot find the Form (runtime error = 2450).

The name of the form is correct in de Query and I made the From visible in the code. (I guess when it is visible it is open?)?

Q: Any ideas what I am doing wrong.

Kind regards,


 
Why not launch the query from the form ? (so you're sure the form is open ...)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Subform? If so, from the query criteria row, utilize the expression builder. Doubleclick thru forms, loaded forms, the main form, subform and then the control. Subforms are not recognized as open forms, but controls on the main form on which they reside. You can also specify the parameter from the query (after you've ensured correct reference) thru the query menu, select parameters. Enter the full reference and datatype.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top