Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Which page of a multipage control to display?

    Hi Loungers

    I am getting an error message about not being able to set focus on a control on a user form.

    The error message states: “Can’t move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus”

    I think it is because I may not have the page of the multipage control displayed when I set the focus to the control. The control is a text box, so I know its visible, and I know it can take focus, and I know it is displayed when the page of the multipage control is displayed.

    How can I pick which page to display when I initialize the user form?

    Thanks

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Is this in a VBA UserForm (MSForms object) or a VB Form?

    Microsoft has this sample code snippet for VBA:

    Code:
        With MultiPage1
            ' The next 2 lines disable Page2 & Page3.
            .Pages(1).Enabled = False
            .Pages(2).Enabled = False
            ' Make Page1 the active page.
            .Value = 0
        End With
    Not the most obvious property to set... does it work?

  3. #3
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post
    Thanks You Jefferson
    Yes this is bizarre. I tried MainUserForm.MultiPage1.Visible = True and it did not work. I guess from the example, we can see that the pages collection is base 0 where the first page is index 0, 2nd page is index 1, and 3rd page is index 2 and so forth.
    But my surprise is that you need to enable it, vs. making it visible, what where they thinking??? ;-)
    Any case, I tried it and it works and that is the end of this mystery.
    Thanks again.
    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  4. #4
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    Hi Wassim,

    You don't need to enable and disable the tabs -- they are enabled by default. The example Jefferson posted was probably one of those multi-purpose examples that Microsoft offers. Disabling tabs and making them unclickable is probably not the way you want to work with your tabs, unless you want to make your users set something on page 0 before moving on to page 1.

    The MultiPage1.Value = 0 is simply setting the value of the multipage to 0 to display the first page. This is usually the default, but as you design your MultiPage, you might save your project with something other than tab one displayed. Unless you programmatically set the tab to 0, it will display whichever tab was clicked when you saved it. If you then try to set focus in a control on different tab, you will get the error message you mentioned in your post.

    When the tabs are all active, you can use .Value as a way of testing which tab has focus and run code accordingly.

    Best, Kim
    Last edited by kmurdock; 2011-06-04 at 15:56.

Posting Permissions

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