Hitting Enter Key Triggers Field OnClick Event

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

I have a sub form with only one field enabled. There's an On Click
event on this enabled field that opens another form. When I click or right
click
on the form this field becomes 'selected'. If I then press the enter key the
code for the On Click triggers and the form opens.
How can I prevent this???
I've trapped the enter key in the On Key Down using:

If KeyCode = vbKeyReturn Then

End If

Didn't work though.

Any help will be appreciated,
James
 
JamesJ said:
I have a sub form with only one field enabled. There's an On Click
event on this enabled field that opens another form. When I click or right
click
on the form this field becomes 'selected'. If I then press the enter key
the
code for the On Click triggers and the form opens.
How can I prevent this???
I've trapped the enter key in the On Key Down using:

If KeyCode = vbKeyReturn Then

End If

Didn't work though.

Any help will be appreciated,
James

You missed one line:

If KeyCode = vbKeyReturn Then
KeyCode = 0 'This "throws away" the keypress
End If
 
Back
Top