X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Sendkeys Without Turning Off Numlock, Access 2016    
post Sep 12 2019, 08:58 AM

Posts: 458
Joined: 5-July 07

I am using buttons on a form to copy specific data to paste into a Chrome browser. I am currently using to (SendKeys ("%{TAB}")) to switch back to Chrome to paste the copied data. The problem is that it turns off my NumLock. I have used the (SendKeys "{NUMLOCK}", True), however, that only works every other time I run the code. So I tried to double up on the (SendKeys "{NUMLOCK}", True) in hopes of making it turn off then back on. this is not working. any ideas?

Go to the top of the page
post Sep 12 2019, 09:14 AM

UtterAccess VIP
Posts: 6,899
Joined: 30-June 11

Here's what I'd do, use an API to ensure NumLock is active

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const kNumlock = 144

Public Function NumLock() As Boolean
    NumLock = KeyState(kNumlock)
    If (NumLock = True) Then
        MsgBox ("Num lock was off. Will turn back on now...")
        SendKeys "{NUMLOCK}", True
    Else: MsgBox ("Num Lock stayed on")
    End If
End Function

Private Function KeyState(lKey As Long) As Boolean
    KeyState = CBool(GetKeyState(lKey))
End Function

Sub myMainMethod()
    'do a function here that includes .SendKeys
    Call NumLock
End Sub

taken from https://stackoverflow.com/questions/2597793...-in-access-form

You may also like to review http://access.mvps.org/access/api/api0046.htm

Daniel Pineault (2010-2019 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc

All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
post Sep 12 2019, 01:27 PM

Posts: 458
Joined: 5-July 07


Thank you for your reply. I shall try that.

Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    14th October 2019 - 08:21 PM