Question

Access Tabs dynamically on Access Forms

Asked by: gfranco

Hi, I need to have a code that allow me to load different subforms upon depend which tabs I hit it.
Each subform is being named like this fSub[Tab Name], etc
How can I accomplish to accelarate the performance,

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-01-13 at 13:50:09ID24049245
Tags

Microsoft

,

Access 2003

Topics

Microsoft Access Database

,

Access Forms

,

Access Coding/Macros

Participating Experts
3
Points
500
Comments
34

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Subforms Subform on another tab in tab control
    I have a sub form on one of the tabs on a two tab control. I have added a subform to that subform and it is working fine. I would like to move the second subform to the 2nd tab control. If I cut and paste the master/child link is broken. How can I accomplish this?
  2. tab from subform to subform
    I have an Access form and a SQL database. I have a form with 3 subforms. Each subform has multiple fields. When I'm done filling out all the fields in the first subform I want to hit tab and go to the 1st field in the 2nd subform etc. Right now I just go around in circles...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: pteranodon72Posted on 2009-01-13 at 15:00:56ID: 23368309

For best performance, you want to use a single subform control and have it load a different source object each time the tab is changed.

Let's call your subform control scfChild.  Instead of placing it on one page of the tab control, create it on the Detail section of the form, move it over the tab control and use Format->Bring to Front to make it appear in front of the tab control and in front of every page. Size it big enough to hold the largest subform to avoid annoying scrollbars.

In the tab control's Change event:

Select Case myTabControl.Value
Case 0:
  sfcChild.SourceObject = "fSubDB Rate"
'If necessary, change the Child/Master Link Fields also:
'sfcChild.LinkMasterFields = "your field(s)"
'sfcChild.LinkChildFields = "your field(s)"

Case 1:
  sfcChild.SourceObject = "fSubSN Rate"
Case 2:
  sfcChild.SourceObject = "fSubPID Rate"
.
.
.

'you'll continue until Case #pages - 1
--------
Set the SourceObject of the subform to the default tab's subform name.

HTH,

pT

 

by: TextReportPosted on 2009-01-14 at 00:49:34ID: 23370823

"How can I accomplish to accelarate the performance" you will take a performance hit both ways.

If you load all your tabs with all your subforms then the hit will be when the form opens.
If you use a single subform control then the hit will be when the user moves from 1 tab to the next, or geos back to a tab
Finally you could have separate subform controls on each tab but not load them until the user selects that tab. This eliminates the need to load a tab you have already loaded.

Cheers, Andrew

 

by: gfrancoPosted on 2009-01-14 at 08:15:02ID: 23374176

Each tab is one subform that I used

fSubSNPDIRate
fSubDBMRAte
fSubSNRate
fSubSiteKeyPIDRate
fSubMasterRate
Each subform has a control source which is dependable from query.

How the code looks like?

Thanks

 

by: RgGray3Posted on 2009-01-14 at 08:53:20ID: 23374700

To get the maximum performance

The subform should exist but not be connected (Design and place the subform, create the parent child relationship then remove the source object from the properties page)
It should "Load" the subform when the tab is selected
it should not "reload" if you return to the tab after it has been loaded...  it should already be there with data waiting
(If you set the  .SourceObject a second time it will reload and requery...  adding additional overhead)


Then in the OnChange of the tab control you select case of the tabname

Replace <CtrlName> with your control name
   
  Select Case <CtrlName>.Pages.Item(<CtrlName>.Value).Name
        Case "pgClinicalStatus"
            '---------------------------
            'Clinical Status Review
            '---------------------------
            With Student_ClinicalStatusReview_sfrm
                If .SourceObject = "" Then
                    .SourceObject = "Student_ClinicalStatusReview_sfrm"
                End If
            End With
       
        Case "pgCoursesTaken"
            '---------------------------
            'Student Course Review
            '---------------------------
            With Student_Courses_sfrm
                If .SourceObject = "" Then
                    .SourceObject = "Student_Courses_sfrm"
                End If
            End With
           
Etc...

 

by: gfrancoPosted on 2009-01-15 at 11:37:15ID: 23386864

This is my design structure.

So, I am trying to follow your suggestion but i am not quite sure.

I have one subform on each tab control, on the first one I have two which it is another subform with chart view.
The tab control does not have on change event, so I am quite confuse,

thanks for any clarification.

 

by: RgGray3Posted on 2009-01-16 at 06:16:41ID: 23392921

The tabs do not have a change event but the tab control does.
Select the grey area to the right of the last tab and you have selected the whole tab control

Now...
For which ever tab has focus when you first open the form....  make no changes...  you want the data to show....  
After you have designed each of the other tabs and have placed and connected the subforms on each of the tabs...
Select the Subform control (not the form within the subform) and when you check its properties you delete the Source object value leaving the parent child information intact.

the ...  Select Case <CtrlName>.Pages.Item(<CtrlName>.Value).Name
 will return the name of the tab/page selected...  (naming convention is always important to clear code, do not use default names)

Let's say your tab control is called tabStudentInfo and each page is called pgCoursesTaken, pgClinicalStatus, pgPreviousEducation
when I click on the tab for the page CoursesTaken the select statement  tabStudentInfo.Pages.Item(tabStudentInfo.Value).Name will return "pgCoursesTaken"

the block of code from my prevous message will then reattach the subform if it is not already loaded

                If .SourceObject = "" Then
                    .SourceObject = "Student_Courses_sfrm"
                End If

this allows the main form to load quickly and display without loading a dozen subforms with their corresponding data.

The way I understand the process, subforms must load before the main form displays.  This makes heavy forms slow.
By loading the subforms on demand the main form can load and display without waiting for the additional data (that may or may not be needed) to load

 

by: gfrancoPosted on 2009-01-16 at 12:43:51ID: 23397200

Hi, I am quite confuse

What will be the process?
So far I did this
1. Created a main form, which is frmMain
2. I have several multiples forms fsubSNRate, FsubDBRate, etc...
3. So in the main form (frmMain) I have included tab control and tab control is referenced on each tab by one of this multiples subforms(forms)

And I  am quite confuse creating parent child ones and the code above, any other shot?
Thjanks

 

by: gfrancoPosted on 2009-01-16 at 13:48:13ID: 23397752

So far,
For test propose, I did this created an main form "main"
and on it I placed the tab form "TabCtl0"
And create 2 subforms
subDBRate
subSNRate


Option Compare Database
 
Private Sub TabCtl0_Change()
    Select Case TabCtl0_.Pages.Item(TabCtl0_.Value).Name
        Case "pgDBM"
            '---------------------------
            'Clinical Status Review
            '---------------------------
            With subDBMRate
                If .SourceObject = "" Then
                    .SourceObject = "subDBRate"
                End If
            End With
        
        Case "pgSNRate"
            '---------------------------
            'Student Course Review
            '---------------------------
            With subSNRAte
                If .SourceObject = "" Then
                    .SourceObject = "subSNRate"
                End If
            End With
    End Select
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:

Select allOpen in new window

 

by: TextReportPosted on 2009-01-16 at 14:22:05ID: 23397998

Looks OK to me, watch out for the .CourceObject it may be null rather than an empty string. Aslo in teh With for the subform you may need to state subformname.form
Cheers, Andrew

 

by: gfrancoPosted on 2009-01-16 at 15:24:01ID: 23398488

Andrew,

It is not working "Object Required" message appeared
I did the changes that you suggested

Option Compare Database
 
Private Sub TabCtl0_Change()
    Select Case TabCtl0_.Pages.Item(TabCtl0_.Value).Name
        Case "pgDBM"
            '---------------------------
            'DB Rate
            '---------------------------
            With subDBRate.Form
                If .SourceObject = Null Then
                    .SourceObject = "subDBRate"
                End If
            End With
        
        Case "pgSNRate"
            '---------------------------
            'SN Rate
            '---------------------------
            With subSNRate.Form
                If .SourceObject = Null Then
                    .SourceObject = "subSNRate"
                End If
            End With
    End Select
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:

Select allOpen in new window

 

by: TextReportPosted on 2009-01-16 at 15:33:03ID: 23398555

I normally reference it slightly differently, the select case refers to the TabControl,, The Case refers to the PageIndex property of the page. Also prefix it with Me so it is clear that it is a control rather than a variable.

Cheers, Andrew

    Select Case Me.TabCtl0
        Case Me.pgDBM.PageIndex
                                              
1:
2:

Select allOpen in new window

 

by: RgGray3Posted on 2009-01-17 at 18:47:17ID: 23403461

Both the index and name will work equally well...

However using the Name of the tab rather than it's index allows you to insert tabs or rearrange the order of the tabs without changing the code.

Select Case <CtrlName>.Pages.Item(<CtrlName>.Value).Name
        Case "pgClinicalStatus"

The name remains the same, regardless of the order of the tabs.

 

by: gfrancoPosted on 2009-01-20 at 07:47:01ID: 23421109

Hi,

On both cases I  have the same error message "method or data member not found"

I would appreciate your comments.

Thanks

Option Compare Database
 
Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0_.Pages.Item(TabCtl0_.Value).Name
        'Case "pgDBM"
         Case Me.pgDBM.PageIndex
            '---------------------------
            'DB Rate
            '---------------------------
            With subDBRate.Form
                If .SourceObject = Null Then
                    .SourceObject = "subDBRate"
                End If
            End With
        
        'Case "pgSNRate"
         Case Me.pgSNRate.PageIndex
            '---------------------------
            'SN Rate
            '---------------------------
            With subSNRate.Form
                If .SourceObject = Null Then
                    .SourceObject = "subSNRate"
                End If
            End With
    End Select
End Sub

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:

Select allOpen in new window

 

by: TextReportPosted on 2009-01-20 at 09:02:14ID: 23421921

OK Firstly please check the NAME property of the Tab Control, it probably doesnt have a _ at the end.
Secondly, you need to use either my option or RgGray3's option, you have mixed them.

In my option the Select Case statement is using the value of the tab control which is the currently selected tab and then in the Case it is checking the PageIndex property of the page controls.

Cheers, Andrew

    Select Case Me.TabCtl0
        Case Me.pgDBM.PageIndex

                                              
1:
2:

Select allOpen in new window

 

by: RgGray3Posted on 2009-01-20 at 09:14:34ID: 23422038

Why the underscores??  

Select Case Me.TabCtl0_.Pages.Item(TabCtl0_.Value).Name
                                   
                                     ^                                ^

 

by: RgGray3Posted on 2009-01-20 at 09:25:19ID: 23422134

Yes...  use either
 Select Case Me.TabCtl0_.Pages.Item(TabCtl0_.Value).Name
    with the ...    
    Case "pgDBM"
    Case "otherTabNames"

OR use the ...

Select Case Me.TabCtl0
with ...
        Case Me.pgDBM.PageIndex

But don't mix them

When you inspect the Tab control value  (Me.TabCtl0)  it will return the index value of the tab selected
 the index being the offset from the left...  (0 based... meaning the default tab is tab/page 0)   0,1,2,3,4,5,6,7...   how many tabs do you have...

When you use the .Name property of the selected tab....   you must compare it to the string value  NAME of the tab.

So if you have your tab pgDbm

you either will compare the value of the TabControl to the index value of the different tabs
or
compare the string name value of the selected tab

 

by: gfrancoPosted on 2009-01-20 at 09:31:30ID: 23422196

Andrew,

I fixed the mispelling. But still have a problem run-time error-424

Option Compare Database
 
Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0
         Case Me.pgDBM.PageIndex
            '---------------------------
            'DB Rate
            '---------------------------
            With subDBRate
                If .SourceObject = Null Then
                    .SourceObject = "subDBRate"
                End If
            End With
        
        'Case "pgSNRate"
         Case Me.pgSNRate.PageIndex
            '---------------------------
            'SN Rate
            '---------------------------
            With subSNRate
                If .SourceObject = Null Then
                    .SourceObject = "subSNRate"
                End If
            End With
    End Select
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:

Select allOpen in new window

 

by: gfrancoPosted on 2009-01-20 at 09:33:53ID: 23422220

RgGray3,

I got the same error "run-time error-424"

Thanks for any help

Private Sub TabCtl0_Change()
    'Select Case Me.TabCtl0
    Select Case Me.TabCtl0.Pages.Item(TabCtl0.Value).Name
 
         Case "pgDBM"
         'Case Me.pgDBM.PageIndex
            '---------------------------
            'DB Rate
            '---------------------------
            With subDBRate
                If .SourceObject = Null Then
                    .SourceObject = "subDBRate"
                End If
            End With
        
        'Case "pgSNRate"
         'Case Me.pgSNRate.PageIndex
            '---------------------------
            'SN Rate
            '---------------------------
            With subSNRate
                If .SourceObject = Null Then
                    .SourceObject = "subSNRate"
                End If
            End With
    End Select
End Sub

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:

Select allOpen in new window

 

by: TextReportPosted on 2009-01-20 at 09:38:46ID: 23422265

Firstly qualify the subform control names using Me

            With Me.subSNRate

If the name doesn't appear when you press the fullstop after me then check that the Control Name is correct, it is the name of the control not the name of the subform, again these can sometimes be the same but it is the controlname you need here.

Cheers, Andrew

 

by: RgGray3Posted on 2009-01-20 at 09:47:49ID: 23422370

Make sure that you are using the SubForm Control Name and not the Subforms name when you are testing
(one reason I name the subform control with the Subforms name...  it works)

Make sure the subform control name is subDBRate  

 

by: TextReportPosted on 2009-01-20 at 10:16:19ID: 23422661

I would strongly recommend you adopt a naming convention for all your objects such as tables, fields, forms and controls. The commonly used is the Leszynski/Reddick Guidelines for Microsoft Access and can be found http://www.databasedev.co.uk/naming_conv.html. You can also get mor details if your search the web.

Please note here that the recommendation is for the actual form to be prefixed fsub and the control to be prefixed sub. The reason for this is for easier debugging of code when you are not sure what you are trying to reference.

Cheers, Andrew

 

by: gfrancoPosted on 2009-01-20 at 10:23:41ID: 23422756

Well,

I understood, please check the subform propoerties for each example.
Thanks

 

by: gfrancoPosted on 2009-01-20 at 10:45:25ID: 23422943

Just quick question, I am still confuse.

I just made the changes suggested when I added a new subform object on each tab I was able to navigate well without retrieving the data.
Then, I just added record source to each subform and I got the data, but I think is not was i was looking for.

What will be your suggest?


 

by: TextReportPosted on 2009-01-20 at 12:40:00ID: 23424072

You do not need to use a subform just to contain the subDBRate as you may as well add subDBRate directly to the Page and then set the SourceObject of thesubform control, I beleive you have an extra level of subform that you do not need.

Cheers, Andrew

 

by: gfrancoPosted on 2009-01-21 at 08:47:21ID: 23431421

I would appreciate if you should review my DB, thanks

 

by: TextReportPosted on 2009-01-21 at 09:02:25ID: 23431550

I can't open the database, I suspect you have it as a 2003 DB and I currently only have 2002 on my PC. Sorry Andrew

 

by: gfrancoPosted on 2009-01-21 at 09:18:57ID: 23431702

Hi,

I converted to 97 version, so will be able to open.

Thanks

 

by: TextReportPosted on 2009-01-21 at 09:44:36ID: 23431952

Hi after reviewing the database the code below works. Please note I have added the Option Explicit in the General Declarations section of the module. I would strongly recommend that this is in EVERY module as is eliminates logical errors caused by typos
Cheers, Andrew

Option Compare Database
Option Explicit
 
Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0
    'Select Case Me.TabCtl0.Pages.Item(TabCtl0.Value).Name
 
         'Case "pgDBM"
         Case Me.pgDBM.PageIndex
            '---------------------------
            'DB Rate
            '---------------------------
            With Me.subDBRate
                If .SourceObject = "" Then
                   .SourceObject = "fsubDBRate"
                End If
            End With
        
        'Case "pgSNRate"
         Case Me.pgSNRate.PageIndex
            '---------------------------
            'SN Rate
            '---------------------------
            With Me.subSNRate
                If .SourceObject = "" Then
                   .SourceObject = "fsubSNRate"
                End If
            End With
    End Select
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:

Select allOpen in new window

 

by: TextReportPosted on 2009-01-21 at 09:46:31ID: 23431974

To be fair to RgGray3 the code below also works using RgGray3 method of identifying the current page. Cheers, Andrew

Option Compare Database
Option Explicit
 
Private Sub TabCtl0_Change()
    'Select Case Me.TabCtl0
    Select Case Me.TabCtl0.Pages.Item(TabCtl0.Value).Name
 
         Case "pgDBM"
         'Case Me.pgDBM.PageIndex
            '---------------------------
            'DB Rate
            '---------------------------
            With Me.subDBRate
                If .SourceObject = "" Then
                   .SourceObject = "fsubDBRate"
                End If
            End With
        
         Case "pgSNRate"
         'Case Me.pgSNRate.PageIndex
            '---------------------------
            'SN Rate
            '---------------------------
            With Me.subSNRate
                If .SourceObject = "" Then
                   .SourceObject = "fsubSNRate"
                End If
            End With
    End Select
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:

Select allOpen in new window

 

by: TextReportPosted on 2009-01-21 at 09:51:31ID: 23432033

Finally the code below assigns the query to the SubForm/SubReport on the main Form rather that assigning the SubForm that contains a SubForm that contains the query, hope that makes sense.

Cheers, Andrew

Option Compare Database
Option Explicit
 
Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0
    'Select Case Me.TabCtl0.Pages.Item(TabCtl0.Value).Name
 
         'Case "pgDBM"
         Case Me.pgDBM.PageIndex
            '---------------------------
            'DB Rate
            '---------------------------
            With Me.subDBRate
                If .SourceObject = "" Then
                   '.SourceObject = "fsubDBRate"
                   .SourceObject = "Query.qryMetricsDB"
                End If
            End With
        
         'Case "pgSNRate"
         Case Me.pgSNRate.PageIndex
            '---------------------------
            'SN Rate
            '---------------------------
            With Me.subSNRate
                If .SourceObject = "" Then
                   '.SourceObject = "fsubSNRate"
                   .SourceObject = "Query.qryMetricsSNRate"
                End If
            End With
    End Select
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:

Select allOpen in new window

 

by: gfrancoPosted on 2009-01-21 at 12:22:33ID: 23433560

Both cases, works fine. Thanks but just one thing. How can I left by default the first tab view when the form load?

I think we are good.

 

by: gfrancoPosted on 2009-01-21 at 12:32:11ID: 23433652

also, how can you display two forms on the same tab using the same logic above?

 

by: TextReportPosted on 2009-01-21 at 13:20:24ID: 23434141

Q1. How can I left by default the first tab view when the form load?
A1. Leave it bound so it will load.

Q2. How can you display two forms on the same tab using the same logic above?
A2. Add the With End With for the second control in the Case for that page you are concerned with.

Cheers, Andrew

Option Compare Database
Option Explicit
 
Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0
    'Select Case Me.TabCtl0.Pages.Item(TabCtl0.Value).Name
 
         'Case "pgDBM"
         Case Me.pgDBM.PageIndex
            '---------------------------
            'DB Rate
            '---------------------------
            With Me.subDBRate
                If .SourceObject = "" Then
                   '.SourceObject = "fsubDBRate"
                   .SourceObject = "Query.qryMetricsDB"
                End If
            End With
 
            With Me.subDBRate
                If .SourceObject = "" Then
                   '.SourceObject = "fsubDBRate2"
                   .SourceObject = "Query.qryMetricsDB2"
                End If
            End With
        
         'Case "pgSNRate"
         Case Me.pgSNRate.PageIndex
            '---------------------------
            'SN Rate
            '---------------------------
            With Me.subSNRate
                If .SourceObject = "" Then
                   '.SourceObject = "fsubSNRate"
                   .SourceObject = "Query.qryMetricsSNRate"
                End If
            End With
    End Select
End Sub

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:

Select allOpen in new window

 

by: RgGray3Posted on 2009-01-22 at 11:41:25ID: 23442746

>>> Q1. How can I left by default the first tab view when the form load?

Andrew is correct in both answers... but....

IF you have a condition where loading the form or forms on the "Default" tab cause the form to load slowly...  
you can move the same logic (for that default tab only) of assigning the object in the onCurrent or possibly onLoad events.
What we are playing with here is changing the "Percieved speed" of the form load as opposed to the actual speed of the form load.

By not binding and loading these forms when the parent form opens, it "Seems" as if your application is running faster.
Lets say for argument...  your main form has two or more subforms...  and each has a large query over a slow network...   maybe it takes 5 or 10 seconds to run....   you application is slow and no good.

Take that same form and disengage the two subforms, the main form will load almost instantly then you connect them and they blink in a second or two later
Because the main form loaded almost instantly, the user experience is that the form  loaded FAST...    though the total load time for the complete form might actually a tad slower.

This is the difference between real speed and perceived speed...  with perceived speed being what you are judged by.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...