Link to home
Start Free TrialLog in
Avatar of Mike Rudolph
Mike RudolphFlag for United States of America

asked on

Up and Down Arrow keys cause different form to load

Dear Experts,

For some reason when a user uses the up or down arrow keys to move between option button selection on a form and the user gets to the last OR first option button and continues to press either the up or down arrow key another form displays. I tried to disable the arrow keys by setting the form's Key Preview event to 'yes' and using the following code in the form's On Key Press event but the other forms still load.

How can I prevent this from happening?

Thanks!

If KeyCode >= 37 And KeyCode <= 40 Then
   KeyCode = 0
End If

Open in new window

Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Did you turn on the Form Key Preview ... set to Yes ?

mx
Capture1.gif
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Rudolph

ASKER

DatabaseMX,

Yes, I have the Key Preview event set to 'Yes' as I noted. However, I only had code in the "On Key Press" event and not the Key Down event. That worked! Thanks!
Yes ... KeyPress uses KeyAscii and not KeyCode ...

thx.mx