Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Set focus on field not on active page of a multipage
Hello -
I have a VBA form with a multipage control. When the user clicks the SAVE button on the form (it's above the multipage), I need to validate a number of fields on all 4 pages of the multipage control. If a field fails its respective validation, I pop-up a msg box noting the error and then Set Focus on that field. However, if the field that I need to Set Focus on is not on the "active" (i.e. shown) page of the multi-page at the time the user clicks SAVE, I get an error. I have tried using the Multipage1.Value = n to set the correct page before setting focus on the field, but still get an error. Any ideas? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Set focus on field not on active page of a multipage
I couldn't reproduce it.
So just for demo purposes to test: Multipage1 Page1 Textbox1 Page2 Textbox2 Page3 Textbox3 so I loop through all the controls and look for a blank textbox. When found, I take the number from the right side of the textbox name, subtract 1 to get the page index (first page is zero) and assign it to the multipage.value property, then set focus. Private Sub CommandButton1_Click() For Each ctl In Me.Controls If TypeOf ctl Is MSForms.TextBox Then If Len(Trim(ctl.Value)) = 0 Then n = Int(Right(ctl.Name, 1)) Me.MultiPage1.Value = n - 1 ctl.SetFocus Exit For End If End If Next End Sub Worked fine for me -- Regards, Tom Ogilvy " wrote: Hello - I have a VBA form with a multipage control. When the user clicks the SAVE button on the form (it's above the multipage), I need to validate a number of fields on all 4 pages of the multipage control. If a field fails its respective validation, I pop-up a msg box noting the error and then Set Focus on that field. However, if the field that I need to Set Focus on is not on the "active" (i.e. shown) page of the multi-page at the time the user clicks SAVE, I get an error. I have tried using the Multipage1.Value = n to set the correct page before setting focus on the field, but still get an error. Any ideas? Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Set focus on field not on active page of a multipage
If we are working with excel 2003 and the code you suggested are in Private
Sub MultiPage1_Change(), this simply do not work. "Tom Ogilvy" wrote: I couldn't reproduce it. So just for demo purposes to test: Multipage1 Page1 Textbox1 Page2 Textbox2 Page3 Textbox3 so I loop through all the controls and look for a blank textbox. When found, I take the number from the right side of the textbox name, subtract 1 to get the page index (first page is zero) and assign it to the multipage.value property, then set focus. Private Sub CommandButton1_Click() For Each ctl In Me.Controls If TypeOf ctl Is MSForms.TextBox Then If Len(Trim(ctl.Value)) = 0 Then n = Int(Right(ctl.Name, 1)) Me.MultiPage1.Value = n - 1 ctl.SetFocus Exit For End If End If Next End Sub Worked fine for me -- Regards, Tom Ogilvy " wrote: Hello - I have a VBA form with a multipage control. When the user clicks the SAVE button on the form (it's above the multipage), I need to validate a number of fields on all 4 pages of the multipage control. If a field fails its respective validation, I pop-up a msg box noting the error and then Set Focus on that field. However, if the field that I need to Set Focus on is not on the "active" (i.e. shown) page of the multi-page at the time the user clicks SAVE, I get an error. I have tried using the Multipage1.Value = n to set the correct page before setting focus on the field, but still get an error. Any ideas? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I set the focus to a page in a multipage | Excel Programming | |||
Set Focus Problem with Multipage Control | Excel Programming | |||
Set Focus Problem with Multipage Control | Excel Programming | |||
Can I set a page of a Multipage form to active? | Excel Programming | |||
Excel 97 VBA: Multipage set focus method | Excel Programming |