Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
MultiPage Form Question | Excel Discussion (Misc queries) | |||
How do I resize a check box form object in Excel? | Excel Discussion (Misc queries) | |||
Multipage & Spinbutton controls on a form | Excel Programming | |||
Multipage Object on User Form | Excel Programming | |||
Can I set a page of a Multipage form to active? | Excel Programming |