RETURN key does not fire KeyDown/KeyPress event

G

Gerhard Kiessling

Hello,

I'd like to use the RETURN key in my Access form to produce a certain
behaviour inside an OCX control when RETURN is pressed.
For this I'm using the KeyPress/KeyDown events for the Control.

All keys are processed to the events correctly except the RETURN key. When
pressing RETURN it does not enter the KeyPress/KeyDown sub but it's setting
the focus to the next control on the form (like the TAB key does)

Does anyone know how I can prevent this and get an event ON THE CONTROL when
I press RETURN ?

Thanks for any help !

Gerhard
 
A

Allen Browne

The KeyPress event processes only ascii keys, but KeyDown should work.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
G

Gerhard Kiessling

Thanks but .... sorry, KeyDown doesn't work.

The following Sub

Private Sub TheControl_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox "KeyDown " & KeyCode
End Sub

does work for (I think) any other key (I get the MsgBox)
But it's passed completely when pressing RETURN.

any other idea ?

Thank you !
 
A

Allen Browne

Your code works here.
The MsgBox shows "KeyDown 13".
Tested in Access 2003 SP1.

Not sure what the difference is.
Can't imagine that there is another event to process first.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
 
B

Brendan Reynolds

Must be some peculiarity of your OCX, Gerthard. It works fine with the
intrinsic Access controls.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

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