Recordsource property of a subform

  • Thread starter Thread starter Candle
  • Start date Start date
C

Candle

Good Afternoon,

How can I set the Recordsource property of a subform on
the fly.

Thanks
 
Me.sfrmControlName.Form.RecordSource = "SomeQryName"

should do the trick. Where strmControlName is the name of the subform
control on the main form, not the name of the subform itself, unless they
are the same.

HTH
Steve C
 
Candle said:
Good Afternoon,

How can I set the Recordsource property of a subform on
the fly.

Thanks

You have to get at it by way of the Form property of the subform control
on its parent form. From code on the parent form:

Me!SubformControlName.Form.RecordSource = ...

From code external to that form (and assuming the parent is a main form,
not a subform itself):

Forms!MainFormName!SubformControlName.Form.RecordSource = ...

Note that "SubformControlName" is the name of the subform *control* on
the main form, which may or may not be the same as the name of the form
object that it displays.
 
Back
Top