Setting queru parameters

  • Thread starter Thread starter Peter Morris
  • Start date Start date
P

Peter Morris

I have a stored query QU_TRANSACTIONS like this :

SELECT Transaction.date, Transaction.[amount in] AS [In],
Transaction.[amount out] AS Out, Transaction.card,
Transaction.type
FROM [Transaction]
WHERE (((Transaction.Account)=[p_account]));


I have a form FRM_TRANSACTIONS with this query
as its record source. This is a subform on a larger form
called MAIN_FORM


When running code on MAIN_FORM, how do I set
the parameter [p_account] in the query and redraw the
subform?

For example, if I want to set the parameter to 3, what's
the code for that?
 
Peter said:
I have a stored query QU_TRANSACTIONS like this :

SELECT Transaction.date, Transaction.[amount in] AS [In],
Transaction.[amount out] AS Out, Transaction.card,
Transaction.type
FROM [Transaction]
WHERE (((Transaction.Account)=[p_account]));


I have a form FRM_TRANSACTIONS with this query
as its record source. This is a subform on a larger form
called MAIN_FORM


When running code on MAIN_FORM, how do I set
the parameter [p_account] in the query and redraw the
subform?

For example, if I want to set the parameter to 3, what's
the code for that?

The standard way to do that is to use a hidden text box in
the form's header/footer section. The query's parameter
would then look like: Forms!FRM_TRANSACTIONS.textboxname

To change the parameter, just use a line of code to set the
text box's value and requery the form:
Me.textboxname = 3
Me.Requery
 
Back
Top