NumLock Key -- Keeping it On(?)

  • Thread starter Thread starter croy
  • Start date Start date
C

croy

On some data-entry forms, I'd like to neutralize accidental
hits to the NumLock key (that would turn it off).

I tried this:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As
Integer)

If KeyCode = vbKeyNumlock Then
DoCmd.CancelEvent
Else
End If

End Sub

.... but it doesn't seem to work.

Any thoughts appreciated.
 
Try:

If KeyCode = vbKeyNumlock Then
KeyCode = 0
End If

Thanks for the reply Jon, but I haven't been able to get
that to work. I've tried it in the KeyDown event for a
control, and in then in the KeyUp event, but no cigar.

As I think it thru a little further, I'm wondering if maybe
I'm fighting a hardware/firmware issue. The keyboard has an
indicator light for the toggle status of the NumLock key.
I've experimented, using the SendKeys command, and it does
not seem to affect the status of NumLock. Maybe there's
another layer of complexity with such keys...? I seem to
remember that the BIOS can be set for NumLock ON or OFF on
bootup, so there must be *some* way of controlling it... I
dunno!
 
Thanks for the reply Jon, but I haven't been able to get
that to work. I've tried it in the KeyDown event for a
control, and in then in the KeyUp event, but no cigar.

As I think it thru a little further, I'm wondering if maybe
I'm fighting a hardware/firmware issue. The keyboard has an
indicator light for the toggle status of the NumLock key.
I've experimented, using the SendKeys command, and it does
not seem to affect the status of NumLock. Maybe there's
another layer of complexity with such keys...? I seem to
remember that the BIOS can be set for NumLock ON or OFF on
bootup, so there must be *some* way of controlling it... I
dunno!

The "If..." part of that *is* working. If I understand
correctly, the "KeyCode = 0" part is intended to effectively
cancel the keystroke, but that doesn't seem to happen in
this case.

If there is Access VB code for determining the status of the
NumLock key, that might be something to experiment with...
 
Back
Top