Pages on a Tab Control

D

Dwight

I am trying to change the .visible property of a page
(tab) on a tab control based on set variable, but nothing
seems to work.

example:
If cbStatus = 2 then
Page:Active.visible = true
Else
Page:Active.visible = false
End if

Does anyone know how to do this.

Thanks in advance!

Dwight
 
M

Matt Weyland

Try the following code

I am assuming that cbStatus is a combo box. On the click
event for this add this code.

This will hide the sheet for the item selected and store
it as oldsheet. Then once the item is selected again it
will reshow the previously hidden sheet and hide the new
one.

Private Sub cbStatus_Click()
Dim TabCtl As TabControl
Dim pPage As Page

Set TabCtl = Me.TabControl1 'sub in your tabcontrol name
here

Set pPage = TabCtl.Pages(oldPage)
pPage.Visible = True

Dim newpage As Integer
'Need to subtract one because the index number and the
'actual sheet number do not conicide. Inexing starts
'at 0, where the list box started at 1
newpage = Me.Combo3.Text - 1
Set pPage = TabCtl.Pages(newpage)
pPage.Visible = False
oldPage = Me.Combo3.Value - 1

End Sub


Hope this helps.

Matt Weyland
Data Analyst
Stratis Health
(e-mail address removed)
 

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

Top