Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Event On Tab Click

Posted on 2006-07-05
7
Medium Priority
?
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 500 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

610 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