DPlank said:
I'd recommend setting the focus to the WC page as part of your form close event (ie multipage1.wc.setfocus just before you Hide os Unload the form)
I would not agree. This does not cover the initial opening of the form. If you do it with the close event, then...the first opening would not have the action you want. Initialize seems better to me.
SetFocus will indeed return an error as it is not a method for the control.
The
active page of a MultiPage is the MultiPage.Value, where Value is the Index number. The index is 0-based.
MultiPage1.Value = 0 makes the first page the active page of the MultiPage.
MultiPage1.Value = 2 makes the third page (if there is one) the active page of the MultiPage.
Note that if the Value given is out of range, and the instruction is in Userform_Initalize, the userform will not open, as this is a stopping error (run-time error 380).
Note also that MultiPage1.Value = 1 would make the second page the active page of the MultiPage, AND move focus to that page. So say you have a textbox with a TabIndex = 0 (which would normally make it the starting focus when the userform opens).
Code:
Sub UserForm_Initialize()
MultiPage1.Value = 0
End Sub
Even if the textbox is TabIndex = 0, the instruction setting the Value of the MultiPage would move focus to that page.
If this is NOT what you want - ie. what you want is simply to ensure that Page1 is the active page of the MultiPage, and you still want (say) Textbox1 to be the opening focus - then you need to explicitly set focus back to that control.
Code:
Sub UserForm_Initialize()
MultiPage1.Value = 0
TextBox1.SetFocus
End Sub
I have to agree with DPlank regarding the buttons. Why do this? The MultiPage has tabs. Let the user use them.
faq219-2884
Gerry
My paintings and sculpture