enter key within a field on a form

P

Patrick Stubbin

once i type a value for a form field i wish to test if the enter key has been
pressed, if it has i wish to close the form, how do i test for the enter key
being pressed, i know it is chr(13)???
 
O

Ofer

On the KeyDown event of the field enter the code

Private Sub FieldName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
DoCmd.Close
End If
End Sub
 
Top