Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Num Lock getting off by accident and creating problem in records

Posted on 2006-04-01
4
Medium Priority
?
477 Views
Last Modified: 2012-08-14
I use Microsoft Access in my business. I am having a problem with the Num lock key, it gets hit by accident and the keys on the keyboard start acting as Page Up, Down, etc which creates a problem when we are entering a new record.  For instance, I have a form to enter new Contracts, there are some fields that require numeric characters, but when the num lock key is hit by accident, and then a series of numbers are hit in the keyboard, then the form jumps to an older record, due to the num lock being off, and now this records can be changed.  For this reason the data in the older records have been changed as the employee keep hitting the numbers assuming num lock is on.  Is there any way to either make num lock always on even when the num lock key is hit, or something else that can be done within Microsoft Access?
Thanks in advance for the help.
0
Comment
Question by:camilo_gs
4 Comments
 
LVL 30

Expert Comment

by:Irwin Santos
ID: 16352439
Purchase a keyboard with the numlock far away from the keypad.

You can boot in the BIOS to startup with NUMLOCK on.. other than that you need to reinforce accuracy.
0
 
LVL 11

Expert Comment

by:Craig Yellick
ID: 16352651
I found the following on MSDN.Microsoft.com

   http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbadev/html/chapter9retrievingsettingsysteminformation.asp

Supposedly you can control the NumLock state (amongst other key states) using some Windows API calls, though in my quick tests I didn't see any useful effect.  Per the above article, the state of the keyboard is stored in an array of bytes. You retrive the array as it presently exists, set or clear the byte for a specific key, then set it back.  NumLock, CapsLock etc are supposed to be controllable in this manner. I figured you could set the flag to True in your form code module.

Below, the relevant code.

Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long

Private Sub SetKeyState(key As Integer, state As Boolean)
  Dim keys(0 To 255) As Byte
  GetKeyboardState keys(0)
  keys(key) = CByte(Abs(state))
  SetKeyboardState keys(0)
End Sub

My idea was to set the form's KeyPreview to True, then constantly set NumLock=true whenever a key was pressed.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  Call SetKeyState(vbKeyNumlock, true)
End Sub

Unfortunately the WinAPI call did not raise any errors but didn't seem to work, either. Maybe someone else will come up with a fix.

-- Craig
0
 
LVL 4

Accepted Solution

by:
samb39 earned 750 total points
ID: 16356104
This guy recommends using keytweak to just map the numeric keypad keys to the keys above the letters.

http://www.mcse.ms/archive164-2005-5-1639033.html

Get keytweak here:

http://webpages.charter.net/krumsick/
0
 

Author Comment

by:camilo_gs
ID: 16367191
Thanks for your help samb39, it worked pretty well.
0

Featured Post

Industry Leaders: 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

In this article, we’ll look at how to deploy ProxySQL.
What we learned in Webroot's webinar on multi-vector protection.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

564 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