Results 1 to 2 of 2
  1. #1
    dododo is offline Novice
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    26

    When press enter key will log in

    Hi all,
    I make log in form with one button name GO. When we click on GO will log in after I entered correct password and username.
    Here is my code:
    Private Sub cmdgo_Click()
    If Me.txtuser = "123" And Me.txtpassword = "123" Then
    DoCmd.OpenForm "frmpatient"
    DoCmd.Close acForm, "frmlogin"
    Else:
    MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
    txtuser = ""
    txtpassword = ""
    txtuser.SetFocus
    End If
    End Sub
    I don't want to click on button go to log in. After I type username and password already then I press enter so my form will login. I try this code but it is not work.
    Private Sub txtpassword_KeyPress(KeyAscii As Integer)
    If KeyCode = vbKeyReturn Then
    call cmdgo_click
    End If

    End Sub


    Please help me how to do this.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Try the AfterUpdate event of txtpassword.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. On button press should update the year
    By jamril in forum Access
    Replies: 3
    Last Post: 02-26-2013, 11:58 PM
  2. Replies: 3
    Last Post: 11-25-2012, 06:09 PM
  3. Replies: 0
    Last Post: 11-22-2011, 09:10 PM
  4. How to Programmatically Press a Key
    By Osman in forum Access
    Replies: 5
    Last Post: 11-28-2010, 11:07 AM
  5. Updating tables press and hold esc
    By slave138 in forum Access
    Replies: 2
    Last Post: 10-08-2010, 08:10 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