Results 1 to 6 of 6
  1. #1
    wcook101 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    56

    Can i assign keyboard commands in place of a mouse click?


    I have a button that adds a new customer and it does get tedious reaching for the mouse to simply add a new record when data entry could be faster using something an F10 or whatever. Is there a way to assign a keyboard command in access 2016 to replace the need to click the button?
    Thanks

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    include an ampersand before a character in your button caption e.g.


    &New

    will display

    New

    and the click event will run if the user hits caps/alt/n (i.e. Alt-N)

    or use
    &new

    displays

    new

    and the click event will run if the user hits alt/n (i.e. Alt-n)

    you can also put the ampersand elsewhere in the caption e.g.

    New &Project

    if you want to do away with your button, you can assign macros to keys - see this link
    https://support.office.com/en-gb/article/run-an-access-macro-by-using-a-keyboard-shortcut-0d267570-d3da-46eb-9bfb-a3c81af676be

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,235

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is a demo of the code I use.
    Pressing the F11 key opens a different form, hiding the main form. Closing the form and the main form appears again.
    Click in a row for Field3 and pressing F12 will open a different form.

    IMPORTANT!!
    In any form that you want to assign a key combo, open the properties dialog, click on the EVENTS tab. At the bottom, set the Key Preview property to TRUE.


    Don't remember where I found the code......


    EDIT - missed a line (while copy & paste) - fixed now.....
    Attached Files Attached Files

  5. #5
    wcook101 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    56
    I had tried that before this but could not find the "Key Preview" Property. I didnt realize at the time it was a form property. Thanks

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    How about simply pressing the <Enter> key?

    In Design View...with the Command Button selected...go to Properties - Other and set the Default Property to Yes. Pressing <Enter> is now the same as clicking on the button.

    This can only be done for one Command Button per Form.

    Linq ;0)>

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

Similar Threads

  1. Replies: 3
    Last Post: 09-13-2018, 04:10 PM
  2. Replies: 3
    Last Post: 07-11-2017, 01:02 PM
  3. Disable Mouse Right Click
    By data808 in forum Access
    Replies: 18
    Last Post: 03-10-2014, 05:58 AM
  4. Replies: 9
    Last Post: 08-20-2013, 09:59 AM
  5. Mouse click to open form
    By darryl.charles in forum Programming
    Replies: 0
    Last Post: 09-05-2008, 10:33 AM

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