CONTROLING A PAGE IN MULTIPAGE

  • Thread starter Thread starter michael sofianos
  • Start date Start date
M

michael sofianos

hello my friends,

I have a multipage with 5 pages. I have make button to change page forward
or backward.
How i can disable the events of mouse click who change page in a
multipage.


Thanks
 
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.)
 
Thank you very match
it's work perfect



Dave Peterson said:
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.)
 
Back
Top