+ Reply to Thread
Results 1 to 5 of 5

Textbox is being skipped despite code setting focus

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    8

    Textbox is being skipped despite code setting focus

    Hi all,

    I have a BeforeUpdate event for a number of textboxes. My code is as follows:

    Please Login or Register  to view this content.
    Ths last If statement adds a zero in front of a number less than 10 automatically when the user tabs out of the textbox which works perfectly, the only problem being the next textbox (in this case txtmm) is skipped and the focus is set on the textbox after this!

    All my TabIndex are set in correct order. MaxLength is set to 2 and AutoTab is set to True for these textboxes.

    Any help is appreciated.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Textbox is being skipped despite code setting focus

    Hi sandal,

    How does it know what txtmm is?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Textbox is being skipped despite code setting focus

    Is
    Please Login or Register  to view this content.
    a type-O is it
    Please Login or Register  to view this content.
    ?

  4. #4
    Registered User
    Join Date
    08-10-2012
    Location
    NZ
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Textbox is being skipped despite code setting focus

    txtdd and txtmm are names of textboxes on the userform. I had the maxlenght property set to 2 so it would autotab if the number entered met my requirements. If the length of the textbox was 1 (i.e. a number less than 10) and the user manually tabbed, I wanted a zero automatically added to the front to make the length 2 then tab to the next textbox.

    I have figured out a way to make this work now. I have taken off AutoTab (But still keeping the TabIndex order) and created some change routines for my textboxes. e.g:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    This is now working

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Textbox is being skipped despite code setting focus

    Glad you got it figured out!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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