Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check for any data changes in a form with multipage object

Ive created a form containing a multipage form. Each page of the form
contains multiple text boxes for user input. Prior to the user clicking to
go to another page of the form, Id like to do some validating . I know I
could use the on Exit event for each text box, but prefer instead to
trigger based on trying to exit the page.

Ideas?
Thanks,
Bert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Check for any data changes in a form with multipage object

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
'----------------------------------------------------------------
"Bert Neuenschwander" wrote:

Ive created a form containing a multipage form. Each page of the form
contains multiple text boxes for user input. Prior to the user clicking to
go to another page of the form, Id like to do some validating . I know I
could use the on Exit event for each text box, but prefer instead to
trigger based on trying to exit the page.

Ideas?
Thanks,
Bert

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Check for any data changes in a form with multipage object

by the way, by exiting the page i assumed you meant when you click another
page of the multipage.
Seb

"sebastienm" wrote:

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
'----------------------------------------------------------------
"Bert Neuenschwander" wrote:

Ive created a form containing a multipage form. Each page of the form
contains multiple text boxes for user input. Prior to the user clicking to
go to another page of the form, Id like to do some validating . I know I
could use the on Exit event for each text box, but prefer instead to
trigger based on trying to exit the page.

Ideas?
Thanks,
Bert

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MultiPage Form Question NFL Excel Discussion (Misc queries) 4 December 30th 09 02:21 PM
How do I resize a check box form object in Excel? bpoole Excel Discussion (Misc queries) 1 May 11th 06 06:38 PM
Multipage & Spinbutton controls on a form Bhuktar S Excel Programming 1 April 21st 04 01:50 PM
Multipage Object on User Form Paul Cheers Excel Programming 2 November 27th 03 11:40 AM
Can I set a page of a Multipage form to active? John T Ingato Excel Programming 2 October 11th 03 12:15 AM


All times are GMT +1. The time now is 05:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"