MultiPage Control

D

Diamonds_Mine

I have a form that contains a multipage control with 4 pages; there are also
4 buttons on the form "Cancel", "Previous", "Next" and "Finish. I'd like to
know how to code the Previous and Next buttons so that they are
enabled/disabled when appropriate. I used the code below, but it disables
the "Next" button after one click and also with the "previous" button. I'd
like the "Next" button to be enabled on pages 1 thru 3 and disabled on page
4; I'd like the "Previous" button to be enabled on pages 2-4 and disabled on
page 1. Thank you for any help that you can provide.

Private Sub cmdNext_Click()
Select Case mpgTab.Value
Case 0 'on General Page
mpgTab.Value = 1
cmdPrevious.Enabled = True
cmdNext.Enabled = False
cmdFinish.Default = True
End Select

End Sub

Sub cmdPrevious_Click()
Select Case mpgTab.Value
Case 1
mpgTab.Value = 0
cmdPrevious.Enabled = False
cmdNext.Enabled = True
cmdNext.Default = True
cmdFinish.Default = False

End Select

End Sub
 
J

Jonathan West

Hi Mike

Try this. it should operate as follows

When you click next, if you have moved to the last page it will
- Disable the Next Button
- Enable the previous Button
- Set the Finish button as default

otherwise it will
- Keep the Next Button enables
- Enable the Previous Button
- Not set the Finish button as default

Similarly, clicking Previous, if moving to the first page it will
- Disable the Previous button
- Enable the Next button

otherwise both buttons will be enabled.


Private Sub cmdNext_Click()
mpgTab.Value = mpgTab.Value + 1
If mpgTab.Pages.Count - mpgTab.Value = 1 Then
cmdNext.Enabled = False
cmdFinish.Default = True
Else

cmdNext.Enabled = True
cmdFinish.Default = False
End If
cmdPrevious.Enabled = True
End Sub

Sub cmdPrevious_Click()

mpgTab.Value = mpgTab.Value - 1
If mpgTab.Value = 0 Then
cmdPrevious.Enabled = False
Else

cmdPrevious.Enabled = True
End If
cmdNext.Enabled = True
cmdFinish.Default = False
End Sub


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
D

Diamonds_Mine

Thank you. This works perfectly!

Jonathan West said:
Hi Mike

Try this. it should operate as follows

When you click next, if you have moved to the last page it will
- Disable the Next Button
- Enable the previous Button
- Set the Finish button as default

otherwise it will
- Keep the Next Button enables
- Enable the Previous Button
- Not set the Finish button as default

Similarly, clicking Previous, if moving to the first page it will
- Disable the Previous button
- Enable the Next button

otherwise both buttons will be enabled.


Private Sub cmdNext_Click()
mpgTab.Value = mpgTab.Value + 1
If mpgTab.Pages.Count - mpgTab.Value = 1 Then
cmdNext.Enabled = False
cmdFinish.Default = True
Else

cmdNext.Enabled = True
cmdFinish.Default = False
End If
cmdPrevious.Enabled = True
End Sub

Sub cmdPrevious_Click()

mpgTab.Value = mpgTab.Value - 1
If mpgTab.Value = 0 Then
cmdPrevious.Enabled = False
Else

cmdPrevious.Enabled = True
End If
cmdNext.Enabled = True
cmdFinish.Default = False
End Sub


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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