Results 1 to 2 of 2
  1. #1
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875

    List Box Not Recognize OnKeyPress ENTER


    I have a menu-style List Box and I want users to be able to just hit the Enter key on their keyboard to select items.

    However, the List Box doesn't recognize (at all) when the Enter Key is pressed! I know it's possible to do this because I've done it with Text Boxes before and was wondering if there was some workaround that is needed for List Boxes. . .

    My VBA Code is as follows:
    Code:
    Private Sub ProgList_KeyPress(KeyAscii As Integer)
      MsgBox "Character '" & KeyAscii & "' pressed!"
    End Sub
    Obviously this is just a Stub. The real code would run a Function from one of my Modules.

    When I press the Enter key, absolutely nothing happens (well, it moves the selection to another field)! But when I press any other key, I get the MsgBox just like I'm supposed to.

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Nevermind, I figured it out.

    Apparently, the Key Press Event doesn't always reliably catch non-printing keys (such as Tab, Escape, Enter, etc.).

    After moving the code to On Key Down, it worked exactly as it should.

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

Similar Threads

  1. Replies: 5
    Last Post: 02-06-2011, 04:32 PM
  2. Replies: 8
    Last Post: 09-24-2009, 02:56 PM
  3. Replies: 1
    Last Post: 07-21-2009, 03:01 PM
  4. Access does not recognize field
    By Shingo in forum Reports
    Replies: 0
    Last Post: 06-25-2009, 09:17 AM
  5. Enter Parameter Value
    By plesser in forum Access
    Replies: 1
    Last Post: 11-08-2008, 10:27 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