Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

Set the subforms ControlSource in the tab controls change event.

I  have a main form with a tab control that contains 5 subforms.   This form takes a long time to load due to all the data contained in each of the subforms.  I've done some research on here and it seems a good solution might be to only load the first default tab, and then load the remaining tabs when each is clicked.  However, I'm not sure how to do this.

Any help will be much appreciated. Thanks!
0
Jinghui Li
Asked:
Jinghui Li
  • 4
  • 3
1 Solution
 
PatHartmanCommented:
Remove the SourceObject name from the hidden subforms.  When a tab gets focus, set the SourceObject for that subform.
0
 
Jinghui LiAuthor Commented:
Ok thanks.  It's been a while since I've done any VBA programming, so please bear with me.  Will I do this with case statements inside the On Change event of the tab control?
0
 
PatHartmanCommented:
Yes.  I don't have any examples handy and I don't do this frequently enough to remember the property but it is a property of the tab control.

Select Case Me.yourtab.someproperty
    Case "Pg1"
        Me.sfrmPg1.ObjectSource = "somename"
    Case "Pg2"
        Me.sfrmPg2.ObjectSource = "somename2"
....
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Jinghui LiAuthor Commented:
Thanks for getting me started.  I'll let you know.
0
 
Jinghui LiAuthor Commented:
Me.sfrmPg1.ObjectSource

I don't understand what "sfrmPg1" is referencing.  I have a main form with one tab control that contains 5 pages.  Each of the 5 pages contains a subform.
0
 
PatHartmanCommented:
Each subform control has a Name property.  Usually it is the same as the ObjectSource name but it doesn't have to be.  "sfrmPg1" is the Name property of the control whose ObjectSource you want to set.
0
 
Jinghui LiAuthor Commented:
That is what I thought.  Thanks for the clarification
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now