Recordsource property of a subform

C

Candle

Good Afternoon,

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

Thanks
 
S

Steve Conway

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
 
D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top