+ Reply to Thread
Results 1 to 4 of 4

Userform displaying when Tab key is hit

  1. #1
    Registered User
    Join Date
    03-22-2011
    Location
    Orlando, Fl
    MS-Off Ver
    Excel 2007
    Posts
    15

    Userform displaying when Tab key is hit

    I display a userform when my workbook opens. It is my "splash screen". From there I display other userforms by button clicks. On one userform, VBA does not set the focus to the first textbox. Focus is set nowhere. If I hit the Tab key, VBA displays the "splash screen". On another userform, there is no data entry, just display of information and buttons. If I hit the Tab key on this userform, VBA displays the "splash screen" from there as well. Why is VBA displaying my initial userform when I hit the Tab key on these userforms, and why is VBA not setting the focus on the first textbox on the one userform? The textbox property Tabstop = True and Tabindex = 1.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Userform displaying when Tab key is hit

    Might be easier to diagnose if we can see the file. Any chance you could attach a desensitized version?

    Which control on the form has TabIndex = 0? That's usually the one that takes focus on intialize.

    BSB

  3. #3
    Registered User
    Join Date
    03-22-2011
    Location
    Orlando, Fl
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Userform displaying when Tab key is hit

    I've been able to narrow it down to because I am opening a workbook to read values from cells and placing the values in the textbox on the form. It appears to be associate with the actual opening of the workbook.
    For some reason that is destroying the tabbing. The first textbox does have a tabindex of 0.
    Last edited by mwc48910; 02-21-2021 at 05:53 PM.

  4. #4
    Registered User
    Join Date
    03-22-2011
    Location
    Orlando, Fl
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Userform displaying when Tab key is hit

    I found a solution, but I don't understand why it works this way...Say on the splash screen userform, I have a button and the code is

    Private Sub CommandButton1_Click()
    Workbooks.Open (ThisWorkbook.Path & "\" & "abc.xlsx")
    ThisWorkbook.Activate
    Me.Hide
    UserForm1.Show vbModeless
    End Sub

    I open the workbook I want to read data from. Then I have to get control back to the workbook where the userform is defined to display the userform in my current workboo. When Userform1 is displayed, this code is ran...
    Private Sub UserForm_Activate()
    TextBox1.Value = Workbooks("abc.xlsx").Sheets(1).Range("d1").Value
    TextBox2.Value = Workbooks("abc.xlsx").Sheets(1).Range("e1").Value
    Workbooks("scenarios.xlsx").Close
    End Sub

    Only then can I read the data from the workbook and place cell values into the textboxes, and the cursor will appear in Textbox1.
    I thought I should be able to open and read the workbook during the Userform_Activate, but that will cause the cursor to not appear in textbox1 when the userform is displayed.

+ 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] UserForm not displaying correctly
    By dazbear in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2015, 02:17 AM
  2. [SOLVED] Help With Displaying Currency In A Userform
    By VBTroubles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-22-2013, 09:36 AM
  3. UserForm not Displaying Correctly
    By Strugglin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-01-2009, 09:02 AM
  4. Userform for displaying values from a row
    By jgmiddel in forum Excel General
    Replies: 0
    Last Post: 04-25-2006, 04:00 PM
  5. [SOLVED] Userform not displaying correctly
    By Trefor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2006, 05:30 AM
  6. Displaying one userform from another
    By CFD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-06-2005, 01:18 AM
  7. PROBLEM DISPLAYING USERFORM
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2005, 09:06 AM

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