I know you can use the ">" symbol to force the txtbox entry to upper case but what is the VBA code syntax to force the keyboard to uppercase? I'm needing this info for MS Access 2000.
I don't know if it is ethical to change the keyboard setting. I would be very annoyed as a user if the program later required lower case and I continually started typing in upper case as a result. The usual method is to accept any input and change it using Ucase() afterwards. However, for the sake of the exercise, this code will do the job (can check by seeing the light on the keyboard come on).
'---------------------------------------------------
Private Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Long
'-
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
'-
Private Declare Function MapVirtualKey Lib "user32" _
Alias "MapVirtualKeyA" _
(ByVal wCode As Long, ByVal wMapType As Long) As Long
'--------------------------------------------------------
Private Sub CAPS_LOCK_ON()
'- if caps lock off then 'press' key
If GetKeyState(&H14) = 0 Then
Call keybd_event(&H14, _
MapVirtualKey(&H14, 0), KEYEVENTF_EXTENDEDKEY Or 0, 0)
Call keybd_event(&H14, _
MapVirtualKey(&H14, 0), KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End If
End Sub
'------------------------------------------------------
Regards
BrianB
** Let us know if you get something that works !
================================
As BrianB and TopJack said, I wouldn't change a users Caplocks. If the input is in a textbox, you could use the textbox change event to force the input to upper case.
Code:
Private Sub TextBox1_Change()
TextBox1.Text = UCase(TextBox1.Text)
End Sub
Thank you so much for all your quick advise! I agree
with you regarding the ethical part. Perhaps I'll tell my friend to not be so lazy and control the caps himself. I can provide the > and UCase() instead.
It sounds perfect! I didn't any luck with the
SendKeys "{CAPSLOCK}", True
I haven't tried the 1st, lengthy coding one. I'm sure
it will work but it's length is discouraging enough
to tell my friend to "just hit the Caps key LAZY Dude!"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.