Solved Creating shortcut menu (1 Viewer)

Char409

New member
Local time
Today, 08:12
Joined
Jul 12, 2021
Messages
14
I'm trying to make a custom shortcut bar. I know I can change the file type to not be editable and just save a backup to edit, don't want to do that. I want to have this one database not be editable unless I want to edit it. I know I can go to options and disable the menus. I have the menus turned off but I want the user to still be able to sort and filter one of the forms. If I allow the shortcut menu, they can just right click and go to design view and mess with things so I want to create a custom shortcut menu when you right click to only allow filter and sorting essentially, so I found this code. I went to tools and references and added Microsoft office 16.0 object library since the website said to add Microsoft office 15.0 object library I assume it's just out of date and then I copied and pasted the code and I get invalid procedure call or argument error when trying to run it. Any help?
Untitled.jpg

I got this code from: https docs.microsoft.com/en-us/office/vba/access/concepts/miscellaneous/create-a-shortcut-menu-for-a-form-form-control-or-report
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 05:12
Joined
Oct 29, 2018
Messages
21,455
Hi. Welcome to AWF!

If you try to use Intellisense, do you see if there's any difference in the required arguments between the code you pasted and the one that's required by your new version of Office?

PS. I just gave it a try using Access 2016, and it worked fine for me. No errors.
 
Last edited:

Char409

New member
Local time
Today, 08:12
Joined
Jul 12, 2021
Messages
14
Okay, so the weird thing is if undo everything, delete the module, close everything out and reopen it, create a new module, put in the code it works the first time, if I run the module again it stops working. Am i not supposed to put it as a module?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:12
Joined
Oct 29, 2018
Messages
21,455
Okay, so the weird thing is if undo everything, delete the module, close everything out and reopen it, create a new module, put in the code it works the first time, if I run the module again it stops working. Am i not supposed to put it as a module?
Well, when you run it the first time, it creates the shortcut menu. So, when you run it the second time, it might produce an error since the menu you're trying to create (again) already exists.
 

Char409

New member
Local time
Today, 08:12
Joined
Jul 12, 2021
Messages
14
So, the set cmbrightclick = nothing doesn't seem to be working then. that line should clear it so it can be run again, right? is there something else that needs to be added or that line changed in some way?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:12
Joined
Oct 29, 2018
Messages
21,455
So, the set cmbrightclick = nothing doesn't seem to be working then. that line should clear it so it can be run again, right? is there something else that needs to be added or that line changed in some way?
No, that's not it. To "clear" a custom shortcut menu, you'll have to use the .Delete method of the CommandBar object.

CommandBar.Delete method (Office) | Microsoft Docs
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:12
Joined
Oct 29, 2018
Messages
21,455
Put another way, when you create a custom tool/shortcut bar, it's permanently created. You're supposed to run that creation code only once. To edit the tool/shortcut bar you just created, you can delete it first and then run the creation code again (with your new design changes).

Hope that makes sense...
 

Char409

New member
Local time
Today, 08:12
Joined
Jul 12, 2021
Messages
14
Oh, well I feel dumb now because i was setting it to open on the form but then i could just close the form and reopen it which was throwing the error so i just moved it to open with the main menu and now it works perfectly. Thank you so much for the quick replies and helping me.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:12
Joined
Oct 29, 2018
Messages
21,455
Oh, well I feel dumb now because i was setting it to open on the form but then i could just close the form and reopen it which was throwing the error so i just moved it to open with the main menu and now it works perfectly. Thank you so much for the quick replies and helping me.
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom