Passing a parameter from a form to a query

G

Guest

I have a query, qryBudgetTotals, that requires a parameter, BudgetAmount. When I run the query by itself, it prompts me for the Parameter, then runs fine. I wish to use a form now to call the query. I am using a text box on the form, txtBudgetAmount, to prompt the user for the parameter. But now I can’t figure out how to get the txtBudgetAmount to the query. How to I call the query using the form and pass the parameter? I can’t seem to figure this one out

I tried loading the query as the recordset in the form parameter, and that failed. I also tried coping the complete sql statement into VB, then doing a recordset = form, sql statement, but that is failing also. I realize there is probably an easy way to do this, but I haven’t been able to figure it out

In the criteria box of hte query column used as a parameter I have a (select statement) so I don't know how to pass the info

I am new to Access and appreciate your help

Thanks
Mik
 
J

Jeff Boyce

Mike

In the query's Selection Criterion, use an expression that points to the
value on the form. The syntax may vary, but it will look something like:

Forms!YourFormName!txtBudgetAmount

Note that this will work only when the form is open and a budget amount
entered. Consider adding a command button on your form that checks for a
valid value in the control, then launches the query.
 

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