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