Results 1 to 4 of 4
  1. #1
    crimedog is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    141

    Set Focus to TextBox

    I have a DB that opens to my Log In Form and Minimizes the Access Program.
    I need the focus to go to the Log In Form TextBox TxtUserName
    This is what U have:
    Code:
    Private Sub Form_Load()
    DoCmd.RunCommand acCmdAppMinimize
    Forms("0Frm_LogIn").SetFocus
    End Sub
    I have tried various versions and adding the set focus to the actual TextBox - no luck



    The TabIndex for the TxtUserName is 0 - so it should be first

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You don't explicitly reference the control itself, so try doing so:

    Forms("0Frm_LogIn")!txtUserName.SetFocus

    (Is the name of your form really "0Frm_Login", or is the "0" a mistake?)

  3. #3
    crimedog is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    141
    Yeah I had that on the line after

    Code:
    DoCmd.RunCommand acCmdAppMinimize
    Forms("0Frm_LogIn").SetFocus
    Forms("0Frm_LogIn")!txtUserName.SetFocus
    It still does not set the focus

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    FYI - Can't tell if the first character is a zero (0) or an oh (o). If it is a zero, the Access Gnomes can get persnickety when object names begin with a number.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Send to last textbox that had focus
    By rs2k in forum Forms
    Replies: 5
    Last Post: 09-11-2014, 08:31 AM
  2. Replies: 3
    Last Post: 07-09-2014, 02:49 PM
  3. Replies: 1
    Last Post: 06-18-2014, 09:39 PM
  4. SET focus back to TEXTBOX if validation does NOT pass
    By taimysho0 in forum Programming
    Replies: 5
    Last Post: 12-04-2011, 10:10 PM
  5. Replies: 1
    Last Post: 05-29-2010, 02:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums