Refer to value in a controloin a form from a query?

  • Thread starter Thread starter Jerry
  • Start date Start date
J

Jerry

I have a form with a subform containing a crosstab query in whose WHERE
clause I'd like refer to the value in a combo that lives in another subform
so I can requery the crosstab in the combo's afterupdate event.
Can I do this, or do queries work only with values stored in tables?
 
Jerry,

You certainly can. The way to make a criterion in a query read a value from
a form control, is:

[Forms]![FormName]![ControlName]

in the criterion line in the grid. In your case, the control being on a
subform, it should be like:

Forms![FormName]![SubFormName]![ControlName]

Note that this will just fine in any other query, but in a crosstab in
particular you will also need to declare it as a parameter under Query >
Parameters.

HTH,
Nikos
 
Thank you, Nikos.
I thought it was ALMOST working in the query by itself until I tried it on
the subform.
Didn't know about parameters.

Jerry

Nikos Yannacopoulos said:
Jerry,

You certainly can. The way to make a criterion in a query read a value from
a form control, is:

[Forms]![FormName]![ControlName]

in the criterion line in the grid. In your case, the control being on a
subform, it should be like:

Forms![FormName]![SubFormName]![ControlName]

Note that this will just fine in any other query, but in a crosstab in
particular you will also need to declare it as a parameter under Query >
Parameters.

HTH,
Nikos

Jerry said:
I have a form with a subform containing a crosstab query in whose WHERE
clause I'd like refer to the value in a combo that lives in another subform
so I can requery the crosstab in the combo's afterupdate event.
Can I do this, or do queries work only with values stored in tables?
 
Back
Top