Solved

Up and Down Arrow keys cause different form to load

Posted on 2011-03-13
4
410 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:shogun5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 75
ID: 35124718
Did you turn on the Form Key Preview ... set to Yes ?

mx
Capture1.gif
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 35124723
Also ... you need to use the Key Down event, which has KeyCode:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyUp Or KeyCode = vbKeyDown Then
        KeyCode = 0
    End If
End Sub

mx
0
 

Author Closing Comment

by:shogun5
ID: 35124866
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!
0
 
LVL 75
ID: 35124878
Yes ... KeyPress uses KeyAscii and not KeyCode ...

thx.mx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question