Tab Control Problem (1 Viewer)

Supertension

New member
Local time
Today, 19:31
Joined
Dec 16, 2015
Messages
13
Hi,
I have three tab controls on a form.
I can get the active control name using Screen.ActiveControl.Name
I also need to be able to get the name of the tab control and the name of the tab control page on which the active control sits.
Can anyone tell me how to do this please?
 

Ranman256

Well-known member
Local time
Today, 14:31
Joined
Apr 9, 2015
Messages
4,337
in the tab properties, get the name (below mine is TAB1)
the code below alters the sub form on top of the tabs, depending on what the user clicks.
it uses the CHANGE event on the tab object. Each tab has a value (and a caption)

Code:
Private Sub Tab1_Change()
Select Case (Tab1.Value)
  Case 0     'projects
     chd.SourceObject = "Query.qsProjNdx1Co_CoFrm"
    
  Case 1    'employees
   chd.SourceObject = "Query.qsEmpsNdxAct"
    'MsgBox "EMPS"
  
  Case 2     'payments
      chd.sourceobject = "frmPay"
End Select
End Sub
 

ozinm

Human Coffee Siphon
Local time
Today, 19:31
Joined
Jul 10, 2003
Messages
121
As an alternative, you could also grab the active control's parent name.
eg.
MyTabPageName = MyControl.Parent.Name
MyTabsName = MyControl.Parent.Parent.Name

NB: I'm paraphrasing here as I'm nowhere near my Windows machine at the moment.

For a bit more detail, have a look at:
https://msdn.microsoft.com/en-us/library/office/aa173191%28v=office.11%29.aspx
 

Supertension

New member
Local time
Today, 19:31
Joined
Dec 16, 2015
Messages
13
Thanks for your replies. I opted to use ozinm's solution as it gives me greater flexibility.
 

Users who are viewing this thread

Top Bottom