Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Set the subforms ControlSource in the tab controls change event.

Posted on 2014-03-31
7
Medium Priority
?
344 Views
Last Modified: 2014-04-01
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
Comment
Question by:Jinghui Li
  • 4
  • 3
7 Comments
 
LVL 40

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 39967399
Remove the SourceObject name from the hidden subforms.  When a tab gets focus, set the SourceObject for that subform.
0
 

Author Comment

by:Jinghui Li
ID: 39967423
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
 
LVL 40

Expert Comment

by:PatHartman
ID: 39967474
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
Technology Partners: 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!

 

Author Comment

by:Jinghui Li
ID: 39967481
Thanks for getting me started.  I'll let you know.
0
 

Author Comment

by:Jinghui Li
ID: 39967572
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
 
LVL 40

Expert Comment

by:PatHartman
ID: 39967659
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
 

Author Comment

by:Jinghui Li
ID: 39970661
That is what I thought.  Thanks for the clarification
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question