How to set parameter in query before results are being shown in subform

  • Thread starter Thread starter Domac
  • Start date Start date
D

Domac

Hi,

Problem is that i would like to set parameter value in code so subform can
update its contents depending on parameter value.

I have a query that uses parameter "[year]", how to set value to that
parameter in my Form_Load event???

Thanks
Domac
 
I'm pretty sure you can't use a query that takes input parameters as the
record source for a form. The way to achieve the result you're after is to
enter a parameter that points to a control on your open form, e.g.

[Forms]![Form1]![MyTextBox]

You could use this form of parameter if you are entering the Year into a
text box on your main form, or if you can have a (possibly hidden) control on
the main form that derives the Year. One thing to note though, you may need
to requery the sub-form in the Year AfterUpdate event (if it's user input) or
some other event that fires when the Year is changed.
 
Back
Top