+ Reply to Thread
Results 1 to 7 of 7

Set No Focus in Userform Multipage Change Event

  1. #1
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Set No Focus in Userform Multipage Change Event

    Hi Everyone,

    I have a userform that I recently added a multipage to by client request (to split up the fields in a more organized fashion).

    I have quite a few textboxes that launch a calendar date picker when entered or selected.

    The problem is this: When a user changes pages within the multipage, the date-picker launches if there are only date-picker enabled textboxes on that page.

    I don't really want the calendar to launch simply because the multipage selects the first textbox it can.

    Is there a way to set a "no focus" so nothing will be selected until the user does? I know I could add a random textbox or control and set focus to that but I'd really like to avoid that if there is another way.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Set No Focus in Userform Multipage Change Event

    Create a Global Boolean boolPC (booleanPageChange)

    Then in the multi-page, use

    Please Login or Register  to view this content.
    And at the top of every Enter event

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Set No Focus in Userform Multipage Change Event

    Hi Bernie,

    When declaring the Global Variable, do I put the following outside all functions on the userform?

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Set No Focus in Userform Multipage Change Event

    Sorry - the parenthetical section was a remark.

    At the top of a standard codemodule (I'm not sure if userform declarations are truly Global or not, but I am sure that codemodule declarations are):

    Public boolPC As Boolean

  5. #5
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Set No Focus in Userform Multipage Change Event

    Hi Bernie,

    No worries! Usually if I'm unsure I'll try what was verbatim first : p.

    Global Variable Set, Multipage Change event set, added the boolPC if statement to all enter events...and have partial success : /.

    Here's what I'm seeing:

    In Page 1, there are other textboxes not associated with the calendar, so this page loads fine.

    In Page 2 & 3, there are only "Enter-Event" textboxes, no other interact-able controls.

    On the first selection of either Page 2 or 3, the calendar form still loads. However, this only happens once (which is a major improvement) instead of every time I switched between the tabs.

    Thoughts?

    Could it be that the boolPc variable is not being declared fast enough to register upon switching tabs?

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Set No Focus in Userform Multipage Change Event

    It could be the order of the events, which I did not investigate. Try setting boolPC to TRUE in the userform initialize event, and maybe in the Mulitpage's Enter event

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 02-17-2016 at 04:48 PM.

  7. #7
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: Set No Focus in Userform Multipage Change Event

    Ah Bernie! Great Success!

    Adding your last post cleared the calendar from loading in in Page 2, and making sure I also had boolpc=true under the change event removed it from loading from both.

    It makes it so I'll have to explain that they'll have to click out of hte box before they can re-"enter" it to pull up the calendar form, but this is much better than it initializing on its own.

    Thank you for your extremely fast assistance!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. MUltipage Change event
    By pjwhitfield in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2015, 07:57 AM
  2. how to switch multipage page from multipage change event??
    By jed38 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-27-2015, 10:31 AM
  3. [SOLVED] New to Forms-How cancel Multipage change page event?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-02-2013, 08:11 PM
  4. [SOLVED] Userform multipage control - exit event not firing or event order
    By jane serky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2013, 10:23 AM
  5. [SOLVED] VBA, MultiPage with UserForm. Syntax issue. mousemove event.
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-22-2012, 01:59 PM
  6. Userform Multipage Event Change
    By sepandb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2008, 01:40 PM
  7. Is there a VBA Event to Detect Change in ActiveCell Focus?
    By Larry A in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-15-2005, 11:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1