Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET FOCUS TO A PAGE IN A MULTI-PAGE FORM 2

Status
Not open for further replies.

ShellBell

Programmer
Oct 29, 2003
6
US
I have a multipage form that has 2 pages.

The multipage is named multipage1 and page1 is named WC and page2 is name GL.

In the initialize I want to make sure that the WC page is always in the front.

I then want to put a button on the WC page that will put the GL Page on top. I then want to put a button on the GL Page that will put the WC page on top.
 
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)

for the others - do you really need buttons? Why not just allow the user to select the page for WC or GL from the selector?

Shouldn't be a problem if you need button though. |Just set the Click Event for GL to contain

WC.SetFocus

and the Click Event for WC to contain

GL.SetFocus

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
I've tried setting the focus like you recommended., i.e., multipage1.wc.setfocus and I receive the message "Object doesn't support this property or method."

Thanks.

Shelley
 
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
 
Thanks for the correction Gerry - I was going from memory and got the methods mixed up for the controls.

Have a star for the assist!

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
I was going from memory and got the methods mixed up for the controls."

Easy enough to do.

BTW: "Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

just cracks me up.

I used to beta-test in-house applications and our programmers kept on complaining that I would find bugs. Ummmm...uh....I think you are unclear on the concept of beta testing. It is my job to find your bugs. Hey...make my job easier...stopping writing bugs.

These were the same guys who, on a Object-Oriented Design course I took with them, told the instructor that they had no time to do any design. Their job was to write code.

The instructor looked shocked, and then slowly replied...

"then you will write BAD code."

I got very dirty looks when I stood up and applauded.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top