caps and num locks switching off

ryetee

Registered User.
Local time
Today, 04:51
Joined
Jul 30, 2013
Messages
952
USING ACCESS 2010

My user has reported that his caps and num locks gets switched off when entering a particular form and after testing he's right!!

I've googled this and it seems that sendkeys is/could be the culprit.
I do have sendkeys in the code so how do I get around it other than not use sendkeys?

Any ideas?

Can I switch num lock on in VBA?
 
Last edited:
I found this somewhere and use it in Excel for caps on/off. It may/should work from Access :) A bit of research should then give you numlock...

Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Dim kbArray As KeyboardBytes

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Long
Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long


Sub Caps_On_Off()
KeyCode = &H14
GetKeyboardState kbArray
kbArray.kbByte(KeyCode) = IIf(kbArray.kbByte(KeyCode) = 1, 0, 1)
SetKeyboardState kbArray
End Sub
 
Try &H90 (144) for Numlock..., although I think I've misunderstood your issue! Your trying to avoid it being set on/off, not trying to do it...
 
Also...

http ://support.microsoft.com/kb/179987
I added some spaces to allow the link to be pasted!
 
Does it turn the caps on when you go into the form with it initially off?
 
Does it turn the caps on when you go into the form with it initially off?


Caps and num lock are on. Going into the form switches both off.
If I comment out sendkeys then both remain on
 
Try &H90 (144) for Numlock..., although I think I've misunderstood your issue! Your trying to avoid it being set on/off, not trying to do it...

I am trying to avoid it being set to off but I may be able to do that by setting it to on myself in the VBA so I'll give yours a go.
 
Caps and num lock are on. Going into the form switches both off.
If I comment out sendkeys then both remain on

This was a debugging question. I know what you initially said. But could you try the test case that I mentioned?
 
This was a debugging question. I know what you initially said. But could you try the test case that I mentioned?

Sorry misread your post!!

No it doesn't. Only switches them off.
 
The only somewhat reliable source I've found was posted by Gina Whipp, the lady can be found everywhere, states that Windows Vista will turn them off.
 
A quick fix may be something like this. If I read the article right that is ^_^

Code:
Public Function ValidSendKeys(ByVal value As String)
    SendKeys value, True
    DoEvents
End Function
 
A quick fix may be something like this. If I read the article right that is ^_^

Code:
Public Function ValidSendKeys(ByVal value As String)
    SendKeys value, True
    DoEvents
End Function

Thanks for this. Not tried it - got side tracked by Christmas and the New Year and other problems!! I'll give it a go when i Get the chance
 

Users who are viewing this thread

Back
Top Bottom