Get Name of Tab Selected

  • Thread starter Thread starter Alan Z. Scharf
  • Start date Start date
A

Alan Z. Scharf

Hi,

What is the syntax for getting the name of a tab cotrol's tab when a tab is
clicked on?

I need to make a control on the underlying form visible or invisible
depending on which tabs are clicked.

Thanks.

Alan
 
Hi,
you could use the tab controls on change event and check which one is
currently the active tab!
The TabControl has an index value starting at 0.

If Me.YourTabControl = 0 Then
'do whatever to hide your control
ElseIf Me.YourTabControl = 1 Then
'do whatever
Else
'do something else
End If

You could also use a select case statement.
HTH
Good luck
 
You need to use the Change event of the tab control.

Assuming the tab control is called TabCtl0

Private Sub TabCtl0_Change()
MsgBox Me.TabCtl0.Pages(Me.TabCtl0.TabIndex).Name
End Sub
 
Terry,

Thanks for your reply.

1. This does not seem to work.

It is giving the name of the subreport on one particular tab, no matter
which tab I click.

2. The msgbox code above is apparently referring to an index of items on a
particular tab.

3. If I use msgbox me.tabmain.Value, then I can get the indix number of the
tab clicked.

4. However, I need the name of the tab clicked, not the index number.

I am shifting the tabs around during development and don't want to keep
having to change tab index numbers in code.

5. Do you know how to get the name of the tab selected from its tab index
number?

Thanks.

Alan





Private Sub tabMain_Change()
' Purpose: To recalculate subReports Heights change text entry tabs

ExecutePROC "dbo.sproc_GetSubReportHeights"
'MsgBox Me.tabMain.Pages(Me.tabMain.TabIndex).Name

MsgBox Me.tabMain.Value
' Select Case Me.tabMain.Pages(Me.tabMain.TabIndex).Name
' Case "ManagerReviews"
' Me.treePermalFunds.Visible = True
' Case Else
' Me.treePermalFunds.Visible = True
' End Select

End Sub
 
Terry,

I found this this code will do it: I used your syntax but substituted the
selected tab's index, rather than the index of controls on the selected tab
page.

intPageIndex = Me.tabMain.Value
strPageName = Me.tabMain.Pages(intPageIndex).Name
MsgBox strPageName

Alan
 
The code I posted worked for me but so long as you have something that works
thats fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top