Results 1 to 5 of 5
  1. #1
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231

    Pressing Enter does not work

    I have a form named Password to check for a password to be entered in a text box and open another form. However I have to click a command button in order for it to work. Here is the code I am using; what change do I need to make. I am a real beginner with VBA, but used to be a programmer using Cobol II and SQL in the 80's so I understand logic. Any help would be appreciated. Thanks.

    Option Compare Database


    Private Sub ckPassword_Click()
    If IsNull(Forms!Password!.Text1.Value) Then
    MsgBox "Password cannot be blank. Try again."
    Me!Text1.SetFocus
    Else
    MyPassword = Me!Text1.Value
    If (Forms!Password!.Text1.Value) <> "Oscar" Then
    MsgBox "Wrong Password. Try again."
    Me!Text1.SetFocus
    Else
    MyPassword = Me!Text1.Value
    DoCmd.Close acForm, "Password"
    DoCmd.OpenForm "Deans Page"
    End If
    End If
    End Sub
    Private Sub Text1_Enter()
    End Sub

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    However I have to click a command button in order for it to work
    I do not understand what is working and what is not working. If a command button has focus the user can trigger the On Click event by using the Enter key in their keyboard. As for the code you posted, I do not believe it will work because of the following line ...
    Code:
    If (Forms!Password!.Text1.Value) <> "Oscar" Then
    It would have to be changed to
    If (Forms!Password!Text1.Value) <> "Oscar" Then

    OR
    If (Me.Text1.Value) <> "Oscar" Then

  3. #3
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    On the Password Form I have a text Box with a label that says: Enter Password, followed by the Text Box with an Input Mask of Password, below that is a command button that says Check Password. When I enter the password in the text box, nothing happens, not until I click the command button and the password form closes and the next form opens. How do I get this to work by pressing the Enter Key?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Try this:

    Set the button's DEFAULT property to YES.

    Also, what do you think this code of yours is doing??
    Private Sub Text1_Enter()
    End Sub

  5. #5
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    That did the trick. The code is doing exactly what I want it to do. If no password is entered a message saying no blank passwords allowed, try again comes up, if an incorrect password is entered a message saying wrong password was entered, try again, if the right password is entered the password form is closed and the next for is opened.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-11-2015, 03:28 PM
  2. Replies: 8
    Last Post: 07-24-2014, 02:15 AM
  3. Replies: 17
    Last Post: 11-05-2013, 06:55 PM
  4. Automatic duplication of form when pressing ENTER
    By tanveerksingh in forum Forms
    Replies: 7
    Last Post: 08-15-2012, 10:03 AM
  5. Pressing the Enter key performs a task...
    By Fish218 in forum Forms
    Replies: 6
    Last Post: 03-06-2012, 02:18 PM

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