Results 1 to 2 of 2
  1. #1
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118

    Error with Custom Shortcut Menu

    I'm trying to customize the right-click shortcut menu on the forms in my database. I wrote some VBA in a form's On Load event to create a custom menu, I named the menu, and I changed the form's ShortCut Menu Bar property accordingly.



    When I open the form, it works just fine. But if I close the form, and open it again, I get an error message. Here's the VBA:

    --------------
    Dim MenuName As String
    Dim CB As CommandBar
    Dim CBB As CommandBarButton


    MenuName = "CustomMenu"


    Set CB = Application.CommandBars.Add(MenuName, msoBarPopup, False, False)


    Set CBB = CB.Controls.Add(msoControlButton, 21, , , True)
    CBB.Caption = "Cut"


    Set CBB = CB.Controls.Add(msoControlButton, 19, , , True)
    CBB.Caption = "Copy"


    Set CBB = CB.Controls.Add(msoControlButton, 22, , , True)
    CBB.Caption = "Paste"


    Set CB = Nothing
    Set CBB = Nothing
    -------------------------

    When I run the debugger, it highlights the 5th line, the one that begins with "Set CB = Application...."

    What am I doing wrong here, people??

    Thanks so much for your help.

    Matt

  2. #2
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118
    Okay, nevermind. I figured out a way to make it work.

    I moved the VBA to run after login, so that it only runs once. And I set every form's shortcut menu to "CustomMenu".

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

Similar Threads

  1. Replies: 6
    Last Post: 07-04-2015, 07:57 PM
  2. Replies: 2
    Last Post: 04-27-2015, 02:23 PM
  3. Print Preview Custom Shortcut Menu
    By Swatskeb in forum Modules
    Replies: 2
    Last Post: 05-22-2014, 08:02 PM
  4. Replies: 0
    Last Post: 01-27-2011, 09:58 AM
  5. custom shortcut menu help!
    By ninachopper in forum Access
    Replies: 5
    Last Post: 09-05-2010, 06:27 AM

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