Changing the datasource of a control in a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi:

I'm developing an application using access 2k. The problem i have is the
following:

I have a form with a subform, inside the subform I have a combobox, which
is filled with the result of a certain query by default. What I need is to
change the query depending on a condition based on the current record. The
second query is just like the first one, only changes the where clause.
What I've done is put my code into the OnCurrent Event like this:

Me.Subform.Controls("ComboBox").RowSource = IIf(IsNull(Me.SomeField),
"Query1", "Query2")

But when I run the form I get an error 2455 (Something like i have written
an invalid reference to a form).

What am I doing wrong?

TIA
 
Hi, Mauro.

Controls is a collection of the subform itself, not of the subform control
on the main form. Use the word Form to specify the former:

Me.Subform.Form.Controls("ComboBox").RowSource = IIf(IsNull(Me.SomeField),
"Query1", "Query2")

Hope that helps.
Sprinks
 
Back
Top