Consulting

Results 1 to 6 of 6

Thread: Multipage Focus on UserForm

  1. #1
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location

    Arrow Multipage Focus on UserForm

    Hi,

    I have a UserForm with a multipage on it (2 pages). I want to be able to always have the focus on Page 1 when the UserForm is loaded. I've got this so far ...

    Private Sub UserForm_Initialize()
        MultiPage1.SetFocus
    End Sub
    but it doesn't seem to work. Anybody know the correct syntax I should be using here? Thanks.

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Zack,

    I hope I understand what your trying to do...I think you want page 1 to be on top every time you open your multipage form...

    I tried this several times and it worked for me. In the VBE set the page you want to be on top....I think the way you leave it in the VBE is the way it will show when you call it.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Tutor jamescol's Avatar
    Joined
    May 2004
    Location
    Charlotte, NC
    Posts
    251
    Location
    Zack,
    To ensure the first page is always the default, use the following code in the form's initialize event:



    'Page 0 is the first page
    MultiPage1.Value = 0

    Cheers,
    James
    "All that's necessary for evil to triumph is for good men to do nothing."

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    I do the same as lucas. Whatever page is on top in the VBE is the one on top when the form loads. Otherwise set the value property to the page you want, like James said.

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Lucas/DRJ,

    Yes that is the way it works. This is what I have been doing. But I do a lot of editing and troubleshooting on my add-ins and am constantly in and out of the VBE fixing little tweaks and bugs and whatnot. I can't count the times I've gone in and done some editing to page 2 of the multipage and just saved/closed. That's basically what spurred this question on.

    James,

    I'll try your solution out here in a little bit. Thanks for that.

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    James,

    That is good to know, thanks.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •