Solved

Event On Tab Click

Posted on 2006-07-05
7
292 Views
Last Modified: 2008-03-06
I have a form that has a tab control on it that has four tabs.  One of the tabs has a subform on it and one field.  I would like for the following to occur when the user clicks on the 4th tab.

If the one field on the tab is not null then the subform should not be visible else the subform should be visible.  This works on non-tabed forms using the on current but I cant seem to get this to work on a form with tab ctl using the on tab click.
0
Comment
Question by:H-SC
  • 4
  • 2
7 Comments
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 125 total points
ID: 17043332
Try this:

Private Sub TabCtl1_Change()
On Error GoTo Error_Routine

'commits any changes
If Me.Dirty Then Me.Dirty = False
Select Case Me.TabCtl1.Value
    Case Is = 0   'run code for page1...(Me.Page1.PageIndex = 0)
        .............................................
        TabCtl1.Pages.Item(0).SetFocus
    Case Is = 1   'run code for page2......(Me.Page2.PageIndex = 1)
        .............................................
        TabCtl1.Pages.Item(1).SetFocus
    Case Is = 2   'run code for page3.....(Me.Page3.PageIndex = 2)
        .............................................
        TabCtl1.Pages.Item(2).SetFocus
    Case Is = 3   'run code for page4.....(Me.Page4.PageIndex = 3)
        If Not IsNull([yourField]) then
           Me!Subform4.Visible = False
        Else
           Me!Subform4.Visible = True
        End If
        TabCtl1.Pages.Item(3).SetFocus
End Select
Exit_Continue:
        Exit Sub
Error_Routine:
        MsgBox "Error# " & Err.Number & " " & Err.Description
        Resume Exit_Continue

End Sub
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 17043378
PS: You have to replace the subform/field names I used with your own.  Also the dotted lines indicate optional code that you may want to add.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 17046365
<One of the tabs has a subform on it and one field>  Do you mean the 4th tab has a subform and a control?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 1

Author Comment

by:H-SC
ID: 17046390
GRayL,

Yes, only the fourth tab has everything that my question involves.  When the user clicks on that 4th tab then the event occurs (only on the items that pertain to that tab and that screen).

0
 
LVL 1

Author Comment

by:H-SC
ID: 17046401
puppydogbuddy,

I will try...I think that I would only need one section of your code...I would only want to apply this event on one tab/field
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 17046483
You definitely want the If Me.Dirty .....as the first line of your code in the tab control........it centrallly commits (saves) all changes that have occured on any of the individual tabs, reducing the code that has to be written for the individual tabs.  Also, if you only use case 4, be sure you have a case else so that you will be protected from the possibility of "fall thru" code.

                                        PDB  
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 17047030
oops! typo....the prior comment above should have referred to case 3 (for the 4th tab) not case 4.  Tab page indexes start with 0.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now