Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I would have thought that running that again would cause an error because the item has already been added to the commandbars collection, which I believe is a property of the database itself. Anyway, are you sure it's not on your Quick Access Toolbar (assuming you have that visible)? Do you see it listed if you go to Access Options > Current Database > Ribbon and Toolbar Options > Shortcut Menu Bar and check that drop down?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  2. #17
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143
    Sorry for the late response, I had a long weekend away from work.
    I did have it set as the shortcut menu bar on the current database options, but when I opened the database, an error came up saying that it didn't exist.
    I also tried using an auto exec macro, using run code createreportshortcutmenu() but that doesn't work because that function needs to be created every time the database is open in order to be run.
    I haven't found a way to run the module in a macro.

  3. #18
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143
    Aha! I seemed to have figured it out.
    Since the original code is a sub and not a function at all, I created a function that calls the sub.

    Code:
    Public Function CreateShortCut()
    
    Call CreateReportShortcutMenu
    
    
    End Function
    So in the AutoExec macro, I was able to use the RunCode macro with the function CreateShortCut()

    Thanks again for everyone's help!
    I'm sure I'll be back soon.

  4. #19
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Since I don't use macros except for AutoExec, I wouldn't have known off the top of my head that a macro can't call a sub. Why not just make the sub a public function and call it from the macro instead of creating a function to call a sub?
    Anyway, hope your solution is the final one. If so, please remember to mark your thread as solved.

  5. #20
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143
    I don't actually know the difference between a function and a sub, so I just assumed that they worked differently and were not freely interchangeable. So I didn't mess with it. But it works now

  6. #21
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    They are both classed as procedures. The basic difference between them is that a function can return a value but a sub cannot. Perhaps that is why in some cases (such as when calling procedures from custom menus/command bars) only a function can be called, but I don't know what, if anything, that a function returns to a command bar. It's also why you'd use a function in a query field - you have to return something to the query.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Custom shortcut menu ?
    By Lukael in forum Access
    Replies: 3
    Last Post: 02-08-2016, 11:50 AM
  2. Error with Custom Shortcut Menu
    By MatthewR in forum Forms
    Replies: 1
    Last Post: 09-15-2015, 01:17 PM
  3. Unable to create shortcut menu
    By lawdy in forum Programming
    Replies: 36
    Last Post: 05-25-2014, 10:36 AM
  4. Print Preview Custom Shortcut Menu
    By Swatskeb in forum Modules
    Replies: 2
    Last Post: 05-22-2014, 08:02 PM
  5. custom shortcut menu help!
    By ninachopper in forum Access
    Replies: 5
    Last Post: 09-05-2010, 06:27 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