Help with subform?

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

Guest

Hi all, I have a mainform, then there is a subform within a page Tab-control.
How do I, using VBA, change the source object of the subform? I have tried
open the mainform as acdesign, and use

forms!mainform.mysubform.form.sourceobject="newsource"

and it failed to make the change. Any help is appreciated. Thanks.
 
As I seem to recall the source object cannot be changed during runtime.
Others here are free to correct me if I'm wrong. The RecordSource,
however, can be changed freely.

David H
 
Harry said:
Hi all, I have a mainform, then there is a subform within a page Tab-control.
How do I, using VBA, change the source object of the subform? I have tried
open the mainform as acdesign, and use

forms!mainform.mysubform.form.sourceobject="newsource"

and it failed to make the change. Any help is appreciated. Thanks.


It's not the form object you want to modify, it's the
subform **control** that has the SoureObject property.
Assuming the code is somewhere in the main form's module:

Me.mysubformcontrol.sourceobject="newsource"

No need to go to design view for this.
 
Back
Top