Results 1 to 6 of 6
  1. #1
    Osman is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    5

    Question How to Programmatically Press a Key


    Hello,

    I've searched the net but I couldn't find an answer.
    I want to enable INSERT key by Access code.

    I tried these but didn't work.

    SendKeys {INSERT}
    SendKeys {%INSERT}
    SendKeys "{INSERT}"
    SendKeys "{%INSERT}"

    I want the cursor to be on the first character of the field when right arrow key is pressed. I can do this Tools-Options-Keyboard. But I want the first character highlighted as in the image.

    Thank you for your help.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    this really seems irrelevant. isn't there another way to do this without messing around with code?

  3. #3
    Osman is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    5
    Quote Originally Posted by ajetrumpet View Post
    this really seems irrelevant. isn't there another way to do this without messing around with code?
    Yes, there is way... to press the INS key manually.

    I think there must be a way to control the keyboard keys programmatically.

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    I'm sorry Osman,

    my point was that you can eventually do anything if yout ry hard enough. But why do this? Unless you've got a lot of time on your hands, it's not worth it. At any rate, good luck with it!

  5. #5
    SteveH2508 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    In the GotFocus event of your textbox (or possibly the Enter event)

    YourControl.SelStart = 0
    YourControl.SelLength = 1

  6. #6
    DaveT is offline Access Developer
    Windows 7 Access 2010 (version 14.0)
    Join Date
    May 2010
    Location
    Texas
    Posts
    69
    The technique from SteveH2508 works for me in either the On Got Focus or On Enter events.

    For keystrokes, Shift+NumPad 0 toggles Insert equivalent to pressing the Insert key.

    For Win API's, there are some that will toggle keys such as Caps Lock and even Insert. While I can get Caps Lock to toggle on entering a field, I couldn't duplicate what you are looking for.

    But Steve's technique does work.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Programmatically create a ACCDE
    By srbond@hotmail.com in forum Programming
    Replies: 2
    Last Post: 11-18-2010, 08:00 AM
  2. Using a Labels Caption Programmatically
    By ksmith in forum Programming
    Replies: 2
    Last Post: 10-12-2010, 01:10 PM
  3. Updating tables press and hold esc
    By slave138 in forum Access
    Replies: 2
    Last Post: 10-08-2010, 08:10 AM
  4. Replies: 4
    Last Post: 08-17-2010, 02:57 PM
  5. Programmatically make queries read-only.
    By cementblocks in forum Queries
    Replies: 1
    Last Post: 05-14-2010, 10:13 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums