+ Reply to Thread
Results 1 to 7 of 7

Userform textboxes, select first textbox

  1. #1
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    Userform textboxes, select first textbox

    Hi. With the code below, a userform with textboxes shows. Textboxes show contents of cells.
    I want to select the first textbox automatically, as per image below.
    Trying to use ".SetFocus" but will not work.

    Snapshot.png

    FORM CODE
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,295

    Re: Userform textboxes, select first textbox

    It is because you have set focus to the exit button in the 'activate' event.
    'activate' takes place after 'create' & 'initialise'

  3. #3
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    Re: Userform textboxes, select first textbox

    I've commented out the Activate event.
    However it does not resolve.

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,295

    Re: Userform textboxes, select first textbox

    With the activate event commented out the text box DOES take focus.
    the backcolour has been reset by your mouse event, it does not change until mousedown.
    You will need another line of code if you want the backcolour to change at the same time as the setfocus.

  5. #5
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    Re: Userform textboxes, select first textbox

    I have commented out the mouse down event but can't see any focus.
    Perhaps I am asking the wrong question as well.
    As well as the focus, the cursor is also needed.

    Tried the following without success.

    Please Login or Register  to view this content.
    If you see any focus, please attach your workbook.

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,295

    Re: Userform textboxes, select first textbox

    There is no need to set focus.
    The frame is first in tab order and the sole textbox within that frame takes focus.
    I have attached your file with the activate commented out.
    I have inserted one line of code that alters the backcolour of the box with focus and the cursor is present also.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    Re: Userform textboxes, select first textbox

    Thank you for clarifying.
    This resolves the issue in this thread.
    Hopefully the Activate event won't be required.

+ 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. [SOLVED] Apply textbox format to numerous textboxes on userform
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2017, 12:19 PM
  2. [SOLVED] Userform - combining 4 textboxes into 1 textbox
    By fastballfreddy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-03-2017, 07:57 PM
  3. [SOLVED] Select all text in textboxes when i click textboxes in simple way
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2017, 03:27 AM
  4. [SOLVED] How to select all text in textbox when i click textbox "userform"
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2017, 11:30 AM
  5. [SOLVED] Sum three textboxes %age in one textbox on userform
    By xlhelp7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-20-2016, 02:44 AM
  6. Replies: 1
    Last Post: 02-17-2015, 07:11 AM
  7. Set focus and select value on a userform textbox
    By Khaos176 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2013, 04:40 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