Passing a parameter from a form to a query

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
Back
Top