Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
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
How do I set the focus to a page in a multipage Azza Excel Programming 2 November 23rd 04 10:42 PM
Set Focus Problem with Multipage Control sebastienm Excel Programming 0 July 16th 04 10:20 PM
Set Focus Problem with Multipage Control sebastienm Excel Programming 0 July 16th 04 10:20 PM
Can I set a page of a Multipage form to active? John T Ingato Excel Programming 2 October 11th 03 12:15 AM
Excel 97 VBA: Multipage set focus method David Excel Programming 3 October 7th 03 01:55 PM


All times are GMT +1. The time now is 03:52 AM.

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"