Userforms - tabbed pages

  • Thread starter Thread starter sixfivebeastman
  • Start date Start date
S

sixfivebeastman

Hello,
would anyone be able to help me out???
I need the code that, when a command button is pressed, will activat
Page2 of the userform. The tabs for the different pages will be hidde
so the user will be forced to navigate the form using the comman
buttons. Any info would be helpful...thanks
 
Private Sub CommandButton1_Click()
MultiPage1.Visible = True
MultiPage1.Pages(0).Visible = False
MultiPage1.value = 1
End Sub


Private Sub Userform_Activate()
MultiPage1.Visible = False
End Sub


Am I understanding you correctly?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"sixfivebeastman"
 
This is a reply to a similar post--except that person wanted two buttons--one to
go right and one to go left. And he wanted the tabs to be visible, but
disabled.

Maybe you can disable the other pages so the users can't select them except by
using your buttons:

Option Explicit
Private Sub CommandButton1_Click()
Dim NextPage As Long
Dim iCtr As Long

NextPage = Me.MultiPage1.Value + 1

If NextPage = Me.MultiPage1.Pages.Count Then
NextPage = 0
End If

For iCtr = 0 To Me.MultiPage1.Pages.Count - 1
Me.MultiPage1.Pages(iCtr).Enabled = CBool(NextPage = iCtr)
Next iCtr

Me.MultiPage1.Value = NextPage

End Sub

Private Sub CommandButton2_Click()
Dim PrevPage As Long
Dim iCtr As Long

PrevPage = Me.MultiPage1.Value - 1

If PrevPage = -1 Then
PrevPage = Me.MultiPage1.Pages.Count - 1
End If

For iCtr = 0 To Me.MultiPage1.Pages.Count - 1
Me.MultiPage1.Pages(iCtr).Enabled = CBool(PrevPage = iCtr)
Next iCtr

Me.MultiPage1.Value = PrevPage

End Sub

Private Sub UserForm_Initialize()
Dim iCtr As Long
For iCtr = 0 To Me.MultiPage1.Pages.Count - 1
Me.MultiPage1.Pages(iCtr).Enabled = CBool(iCtr = 0)
Next iCtr
End Sub

(You could also hide the tabs by using .visible instead of .enabled.)

======
(make sure you change that .enabled to .visible in all 3 spots.)
 

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