Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Carrollton, Georgia, USA
    Posts
    123
    Thanks
    3
    Thanked 1 Time in 1 Post

    NumLock (97 SR2)

    Hey Guys and Gals! I am having problems keeping my NUM LOCK on. Is there some code to keep the Num Lock on? It sometimes goes off, and sometimes it doesn't. Is there some code that sets the NumLock to On, regardless of it's current status? I'm thinking something like NumLock=True.

    Thanks in advance!
    KST

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: NumLock (97 SR2)

    Is it possible that you have some "Send Keys" code running in your database that is doing it to you? Most PCs have an option in the ROM-BIOS to turn on NumLock on bootup.
    Wendell

  3. #3
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: NumLock (97 SR2)

    As Wendell notes, if you're using multiple SendKeys statements it can turn off NumLock key (& possibly the CapsLock & ScrollLock keys as well). For more info see following MSKB articles:

    BUG: Multiple SendKeys Statement Turns Off NumLock Key

    SendKeys Does Not Work with NumLock or Caplock

    To reliably keep keep NumLock key turned on, it'll probably take more than a simple one-line command - rather, a bunch of convoluted Windows API function calls. For an example (designed for VB but can be adapted for VBA in Access) see:

    HOWTO: Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK Keys

    Bottom line is you can't rely on simple SendKeys statements for NumLock, CapsLock etc functionality, use the API functions.

    HTH

  4. #4
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Carrollton, Georgia, USA
    Posts
    123
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: NumLock (97 SR2)

    Mark, Wendell, Thanks!

    I went to the links Mark posted. Sure enough, there is code there for VBA as follows:

    Private Sub Command1_Click()
    SendKeys "a"
    DoEvents
    SendKeys "b"
    End Sub

    Now guys, don't be too hard on my, but, I'm using Macros, just as you expected. What macro command would "DoEvents" be in Access97? The code I listed does work to solve my problem, but I'm running macros. Should I just insert a Macro action "RunCode"? Do you think that'll work fast enough / effeciently (even though I'm using Macros)?

    Great info. Thanks. Can you help me take it a step further and help me work it with a macro?

    KST

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: NumLock (97 SR2)

    Hello KST,

    You'll have to write at least a bit of Visual Basic code. RunCode can execute a user-defined function, but it can't execute built-in functions directly. To execute a built-in function, you must wrap it in a user-defined function.

    I think it would be worth your while to invest some time in learning a bit of VBA. In the end, VBA is much more flexible than a macro. As a starter, you could write a small user-defined function and execute it from a macro.
    <UL><LI>Switch to the Visual Basic Editor (Alt+F11).
    <LI>Click New to create a new module.
    <LI>To stay with the example in your post:

    Function MyFunc()
    SendKeys "a"
    DoEvents
    SendKeys "b"
    DoEvents
    End Function

    To execute this from a macro, set the Action to RunCode, and type MyFunc() in the Function Name box. That's all![/list]Notes:
    <UL><LI>You can only call functions from a macro, not procedures (procedures begin with Sub ... and end with End Sub).
    <LI>You *must* include the parentheses, even if your function has no arguments.[/list]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •