Combo Box with Caps Lock on

J

Jeannie

I need to be able to keep Caps Lock on while typing a value into a combo box
(Access 2007). It won't select the corresponding value if the caps lock is
on. The user needs to keep the caps lock key on. Any suggestions?
 
D

Dirk Goldgar

Jeannie said:
I need to be able to keep Caps Lock on while typing a value into a combo
box
(Access 2007). It won't select the corresponding value if the caps lock
is
on. The user needs to keep the caps lock key on. Any suggestions?


It seems strange to me that the combo box wouldn't select the correct value
with Caps Lock on. Text comparisons in Access are not case-sensitive. Are
you really saying that, if the item in the combo box is "aaaaa", typing
"AAAAA" won't match that item? That certainly doesn't match my experience.
 
L

Linq Adams via AccessMonster.com

In a new module place this code:

'Windows API/Global Declarations for :CapLock
'*********************************************
Public Const VK_CAPLOCK = &H14

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

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

'************* End Code ************

When prompted name the module something like ControlCapsLock

Then, replacing YourComboName with the ***actual*** name of your own combobox,
use this code:

Private Sub YourComboName_GotFocus()
'Turn Capslock On
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPLOCK) = 1
SetKeyboardState kbArray
End Sub

Private Sub YourComboName_LostFocus()
'Turn Capslock On
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPLOCK) = 0
SetKeyboardState kbArray
End Sub

This will turn the CapsLock on amd off as you enter and leave the combobox.

Having given you this, I have to say that my concern would still be why your
combobox is behaving this way! I'd be worried about corruption of the
combobox control, and would probably, as a first effort, delete the combobox
then re-create it.

The fact is that getting Access to compare text in a case-sensitive manner
takes some deliberate action which can be quite complicated, depending on
where/how you're trying to do it. It certainly shouldn't be doing it here!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top