Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Set Focus Problem for textbox control on multipage control

Thank you in advance for any help on this matter. I have a userform with a multipage control with 7 tabs. Upon clicking on the 2nd tab (Multipage1_Change event), I check some data from the previous page. If it is not correct, I return them to the field that needs to be corrected by using the Multipage1.value command and then a field.setfocus command. This works fine in all versions of Excel except 2003. In fact, the tab will actually return to the previous tab; but the page contents remains that of the second tab. I then get a Run-Time error '2110' - can't set the focus.... If anyone has any info on this, I would be so grateful...have spend about 8 hours researching this problem and have found nothing...thanks, Sue
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Set Focus Problem for textbox control on multipage control

Hi Sue,

I don't have 2003 but i guess part of what happens is:

In the first Change SUb, you set the Value property of the multipage which triggers the Change sub a second time while it has not left the first one yet.

In 2003, it goes back to the 1st tab (for some reason i don't know) before it reaches the SetFocus from a control on another tab (not the active), therefore an error because the tab should be activated before doing a SetFocus.

If, in a basic form containing 1 multipage only, you put the code:
'-------------------------------
Private i As Integer
Private Sub MultiPage1_Change()
i = i + 1
MsgBox i
MultiPage1.Value = IIf(MultiPage1.Value = 0, 1, 0)
End Sub
'--------------------------------
Once you click a tab, it doesn't stop : the next tab is select , then the first, then... (pressCTRL+Break) to stop the code

I would try to *disable* the event handler _Change when you programatically change the Value of the Multipage so that it is not triggered an extra time:
1. At the top of the form, add a variable
Private progMode as boolean 'True if Value changed programaticaly
(when the form is shown, this value is autmotically set to false
2. In the Change event, before settingadd
Private Sub MultiPage1_Change()
if progMode then exit sub 'Not processed if change programmaticaly '...
' your code here
'...
End Sub
3.And finally, anywhere you set the Multipage.Value property programmatically, wrap it with:
progMode = True
MultiPage1.Value= ...
progMode = False

I hope this helps,
--
Regards,
Sébastien

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 control Patrick Simonds Excel Worksheet Functions 1 August 5th 06 05:32 PM
Multipage control tab font R.H. Excel Programming 1 June 4th 04 04:57 PM
MultiPage Control Todd Huttenstine Excel Programming 7 May 13th 04 05:16 AM
MultiPage control George[_18_] Excel Programming 0 February 6th 04 03:33 PM
Multipage control Neil Excel Programming 2 September 15th 03 01:24 PM


All times are GMT +1. The time now is 02:50 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"