Thanks again for all information. Sorry for delay I have been of work.
On Change of the password field has the following code.
On Error GoTo Err_Command0_Click
' Dim kb As New Keyboard Object
Dim kb As New Class1
If kb.Capslock = True Then
!Visible = CapsLockON.Visible
MsgBox "Caps Lock is on"
ElseIf kb.Capslock = False Then
MsgBox "caps Lock is off"
End If
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
It works Except if you want caps in password each letter type brings up the message box. So I tried adding a label next to the password as Tom suggests with:
Me.lblWarn.visible = CapsLock() OR
Me.lblWarn.Visible = True
The code for Caps Lock etc is.
Option Compare Database
' From "VBA Developer's Handbook"
' by Ken Getz and Mike Gilbert
' Copyright 1997; Sybex, Inc. All rights reserved.
' Not all VBA implementations include this constant!
Private Const vbKeyScrollLock = 145
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Property Get Capslock() As Boolean
' Return or set the Capslock toggle.
Capslock = CBool(GetKeyState(vbKeyCapital) And 1)
End Property
Property Get Numlock() As Boolean
' Return or set the Numlock toggle.
Numlock = CBool(GetKeyState(vbKeyNumlock) And 1)
End Property
Property Get ScrollLock() As Boolean
' Return or set the ScrollLock toggle.
' ScrollLock = CBool(GetKeyState(vbKeyScrollLock) And 1)
End Property
Property Let Capslock(Value As Boolean)
' Return or set the Capslock toggle.
Call SetKeyState(vbKeyCapital, Value)
End Property
Property Let Numlock(Value As Boolean)
' Return or set the Numlock toggle.
Call SetKeyState(vbKeyNumlock, Value)
End Property
Property Let ScrollLock(Value As Boolean)
' Return or set the ScrollLock toggle.
' Call SetKeyState(vbKeyScrollLock, Value)
End Property
Private Sub SetKeyState(intKey As Integer, fTurnOn As Boolean)
' Retrieve the keyboard state, set the particular
' key in which you're interested, and then set
' the entire keyboard state back the way it
' was, with the one key altered.
Dim abytBuffer(0 To 255) As Byte
GetKeyboardState abytBuffer(0)
abytBuffer(intKey) = CByte(Abs(fTurnOn))
SetKeyboardState abytBuffer(0)
End Sub
Any help eould be appreciated.
Never give up never give in.
There are no short cuts to anything worth doing
