none
Add custom shortcut keys to VBA editor in Access 2010 RRS feed

  • Question

  • In Access 2003, I had a macro called AutoKeys which I used to assign various actions to keystrokes, e.g., Ctrl-E would invoke a VBA function that would automatically generate an error handler and dim some variables for db, rs and strSQL in a new sub or function. Also, I had assigned various keystrokes to toggle bookmarks in code, goto next bookmark, previous bookmark, and clear all bookmarks. All I had to do was run the AutoKeys macro once during a programming session, and all of those handy shortcut keys would be available in the VBA editor. I migrated my project to Access 2010, but know my handy shortcut keys no longer function. Is there some new way to do this in Access 2010? I really miss my shortcut keys, especially the ones for bookmark management. Thanks!


    Da Bomb

    Monday, October 15, 2012 11:38 PM

Answers

All replies

  • See whether MZ-Tools provides what you're looking for.

    Doug Steele, Microsoft Access MVP
    http://www.AccessMVP.com/djsteele (no e-mails, please!)
    Co-author Access Solutions — Tips, Tricks, and Secrets from Microsoft Access MVPs (ISBN 978-0-470-59168-0)

    Tuesday, October 16, 2012 1:22 AM
  • I agree with Doug completely. mztools is a wonderful add-in.

    I suspect you meant Access 97 for your AutoKeys as starting with 2000, the code editor became separated from the main database part of a file. Thus, AutoKeys stopped working for the things you describe. I know because I used the same kind of macro and was sorely disappointed when I had to switch to Access 2000.


    Bill Mosca
    http://www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Tuesday, October 16, 2012 3:21 PM
  • Perhaps I misunderstand somewhat. I use in A2007, AutoKeys Macro. It is lightweight what I do with it but I don't see why it can't do more. Here is a picture of one of my Apps with AutoKeys Macro...

    Then I have a module with all the Functions in it. Then I call the Functions from whatever key clicks I select.

    Here is more info from the help files

    Run an Access macro by using a keyboard shortcut

    You can assign an action (action: The basic building block of a macro; a self-contained instruction that can be combined with other actions to automate tasks. This is sometimes called a command in other macro languages.) or set of actions to a specific key or keyboard shortcut by creating an AutoKeys macro group (macro group: A collection of related macros that are stored together under a single macro name. The collection is often referred to simply as a macro.). When you press the key or keyboard shortcut, Microsoft Office Access performs the action.

     Note   If you assign an action to a keyboard shortcut that is already assigned to Access, the action that you assign to this keyboard shortcut replaces the Access key assignment. For example, CTRL+C is the keyboard shortcut for the Copy command; if you assign this keyboard shortcut to a macro, Access will run the macro instead of the Copy command.

    Create the AutoKeys macro

      • On the Create tab, in the Other group, click Macro. If this command is unavailable, click the arrow beneath either the Module or the Class Module button, and then click Macro.
    1. On the Design tab, in the Show/Hide group, click Macro Names to display the Macro Name column.
    1. In the Macro Name column, press the key or keyboard shortcut to which you want to assign the action or set of actions.
    2. In the Action column, add the action that you want the key or keyboard shortcut to perform. For example, you can add a RunMacro action that runs the Print Current Record macro when CTRL+P is pressed.

    AutoKeys macro containing PrintRecord macro action

    To assign more than one action to the keyboard shortcut, add the additional actions that you want below the first action. Leave the Macro Name column blank for each succeeding action.

    1. Repeat steps 3 and 4 for any other key assignments that you want to make.
    2. Click the Microsoft Office Button Button image and then click Save, or press CTRL+S.
    1. In the Save As dialog box, under Macro Name, type AutoKeys.

    The new key assignments are available as soon as you save the macro group, and are in effect every time that you open the database. If you want, you can bypass the key assignments (and many other startup options) by holding down the SHIFT key while you start the database.

    Find links to more information about creating macros in the See Also section.

     Important   If the database is not granted trusted status, certain macro actions are disabled. You can enable all macro actions by clicking Options in the message bar, and then selecting Enable this content. This enables all macro actions until you close the database. For more information about permanently granting trusted status to a database, see the links in the See Also section of this article.

    Syntax for AutoKeys keyboard shortcuts

    The following table shows some example keyboard shortcuts that you can enter in the Macro Name column to make key assignments in an AutoKeys macro group (macro group: A collection of related macros that are stored together under a single macro name. The collection is often referred to simply as a macro.). These keyboard shortcuts are a subset of the syntax that is used in the SendKeys statement in Microsoft Visual Basic (Microsoft Visual Basic: A high-level, visual-programming version of Basic. Visual Basic was developed by Microsoft for building Windows-based applications.).

    Macro Name Key or keyboard shortcut
    ^A or ^4 CTRL+A or CTRL+4
    {F1} F1
    ^{F1} CTRL+F1
    +{F1} SHIFT+F1
    {INSERT} INSERT
    ^{INSERT} CTRL+INSERT
    +{INSERT} SHIFT+INSERT
    {DELETE} or {DEL} DELETE
    ^{DELETE} or ^{DEL} CTRL+DELETE
    +{DELETE} or +{DEL} SHIFT+DELETE

    Chris Ward

    Tuesday, October 16, 2012 3:41 PM
  • Sorry this is another one of those cases where I didn't read the question completely. I see you are looking for AutoKeys in the VBA Editor not in your application. I have no experience here.

    I will delete the earlier post if you prefer it not to be there otherwise I will leave it for others to read incase it helps them.


    Chris Ward


    • Edited by KCDW Tuesday, October 16, 2012 4:05 PM
    Tuesday, October 16, 2012 4:04 PM
  • Sorry this is another one of those cases where I didn't read the question completely. I see you are looking for AutoKeys in the VBA Editor not in your application. I have no experience here.

    I will delete the earlier post if you prefer it not to be there otherwise I will leave it for others to read incase it helps them.


    Chris Ward


    Chris - I thought I was the only one who jumped the gun. :O) I see no need to delete your post.

    As I stated, back in Acc 97 the AutoKeys macro could be used to add code to the current module because the editor was not an independent body. Access had its own editor so it could "see" the macros from within the VBE. Starting with 2000, that was not possible.


    Bill Mosca
    http://www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Tuesday, October 16, 2012 6:28 PM
  • Thanks Doug and Bill - I downloaded MZ Tools a few days ago but I have yet to try it out.

    Bill - I stand corrected - that was in Access 97!

    Chris - I agree with Bill - no need to delete your other post as it is potentailly helpful to someone!


    Da Bomb

    Tuesday, October 16, 2012 8:32 PM