Can I run code in a field when the enter key is pressed?

Jon123

Registered User.
Local time
Today, 12:43
Joined
Aug 29, 2003
Messages
668
Right now on a form I have code that runs when the used DoubleClick on that field. Users want to have the code run when the EnterKey is pressed as well but when putting the code in the onEnter command line it would run the code when you tab thru the field.

jon
 
You could make a command button and make it default, so it's Click event is run when you press enter on the form - check out Other tab in the Properties of the button.
 
... or use KeyDown or KeyUp event
Code:
Private Sub ControlName_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode <>13 Then
Exit Sub
  End If

'Your code goes here
End Sub
 

Users who are viewing this thread

Back
Top Bottom