You could use the _Change event, do something like the following:
- mProcessing -- boolean: variable to track when we are checking a Page
validation during the Change event.
- bValidated -- boolean : variable to track if valiudation fails or not.
During the Change event (the new page is already activated), if the
validation fails on the oldPage, the old page needs to be re-activated
programmatically. The sideeffect is that it triggers the Change event again
for a case where we don't want to check validation (we are just setting the
active page back). This is why we use the mProcessing variable, to keep track
of that case. It is similar to the _Change event of a Sheet.... it is common
practice to set Application.EnableEvents to False, process the event, then
setting it back to True)
Regards,
Sebastien
'--------------------------------------------------
' In Userfform
Private mProcessing As Boolean
Private oldPage As Page
Private Sub MultiPage1_Change()
Dim newPage As Page
Dim bValidated As Boolean
If Not mProcessing Then 'if we are not already processing it
mProcessing = True
Set newPage = MultiPage1.SelectedItem
'Check validation of the oldPage
If oldPage Is Nothing Then
bValidated = True
Else
'----- ADD CODE HERE ---------
'Validation code of oldPage
'bValidated=????
End If
If Not bValidated Then 'Set back the old page
MultiPage1.Value = oldPage.Index
Else 'keep new page on
Set oldPage = newPage
End If
'Finish processing change event
mProcessing = False
End If
End Sub
Private Sub UserForm_Initialize()
Set oldPage = MultiPage1.SelectedItem
End Sub
'----------------------------------------------------------------