Detect key pressed in Access VBA

A

Abe Katz

Hello,
How can I detect which key was pressed in Access 2003
Thanks in advance
Abe
 
D

Douglas J. Steele

Detect which key was pressed where?

Most Form controls (text box, combo box, etc.) have a KeyPress event that
you can use.
 
A

Abe Katz

Thanks Doug,
I want to use it on a form. When the enter-key is pressed, I want to run an
event.
 
D

Douglas J. Steele

Set the form's KeyPreview property to True, and you can then use the form's
KeyPress event.

Private Sub Form_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
MsgBox "You hit Enter"
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top