Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle NUMLOCK for Access Basic 97. 1

Status
Not open for further replies.

mastry

Programmer
Dec 27, 1999
5
US
I am trying to make sure the NUMLOCK is on when a particular form is opened. I have tried using a Sendkeys {NUMLOCK} statement in the code but it does not seem to do any thing. <br><br>I can use the test code from Access help(opens the calculator, etc..)in the same event and it works fine.<br><br>Any have any ideas?<br><br>
 
Sendkeys only works in another Application like Calculator<br>You need something different like a Keyboard handler routine.<br>I'll see what I can find. <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
For right Now all I could suggest is putting a Message box line in the OnLoad of your form prompting the user to make sure the Num Lock key is on.<br><br>Private Sub Form_Load()<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Please Make sure the Num Lock Key is On&quot;, vbCritical, &quot;Num Lock Keying Warning&quot;<br>End Sub<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Try this API function:<br><br>Place the following code in a new module:<br>'*********************************************<br>'Windows API/Global Declarations for :NumLock<br>'*********************************************<br>Public Const VK_NUMLOCK = &H90<br>Public Type KeyboardBytes<br>kbByte(0 To 255) As Byte<br>End Type<br>Public kbArray As KeyboardBytes<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>Public Declare Function GetKeyState Lib &quot;user32&quot; _<br>(ByVal nVirtKey As Long) As Long<br>Public Declare Function GetKeyboardState Lib &quot;user32&quot; _<br>(kbArray As KeyboardBytes) As Long<br>Public Declare Function SetKeyboardState Lib &quot;user32&quot; _<br>(kbArray As KeyboardBytes) As Long<br>'********************End Code*******************<br><br>Now add the following code to the form you are opening:<br><br>First add this function to the form:<br><br>Private Function NumLock() As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NumLock = GetKeyState(VK_NUMLOCK) And 1 = 1<br>End Function<br><br>Add this code to the form's On Load event:<br><br>Private Sub Form_Load()<br>GetKeyboardState kbArray<br>kbArray.kbByte(VK_NUMLOCK) = 1<br>SetKeyboardState kbArray<br>End Sub<br><br>This will set the NumLock to ON if it's not already in that state.<br><br>Good Luck<br>RDH<br><br><br> <p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top