Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Posts
    13

    Unanswered: How to use the event "enter"?

    I'm trying to use the event enter with it's ascii (13) in the sub: text_keypress, but it doesn't work. This is the code:

    Private Sub D01_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    MsgBox "hello"
    End If
    End Sub

    this code works properly with other keys, i don't know what happens.
    Thanks.

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Think about it . . .

    Access uses certain special key to transfer BETWEEN controls, like the tab key and the enter key, and never uses these keycodes as data WITHIN a control.

    Realizing that, there is something which does trap these key strokes. You can put this code on the KeyPress event of the FORM, not a control and set the KeyPreview property of the form to YES. The KeyPreview property tells all the controls "if anyone presses a key, I, the FORM KeyPress Event, want to look at that key first."
    Ken

    Maverick Software Design

    (847) 864-3600 x2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •