Hi folks,
Using MS Access 2016. I'm trying to find a list of msoControlButton values to use VBA to create one or more custom shortcut menus. To make it clearer, I'm talking about the lines used in the code, below, for example ".Controls.Add msoControlButton, 141, , , True". The number 141 sets up the Find command.
I haven't done much on shortcut menus since A2003. While I've done some work in A2007 using XML nearly a decade ago, none of which I recall and I don't have access to my code from then. I am using the code below, which was garnered from https://docs.microsoft.com/en-us/off...trol-or-report. I'd really like to find a number of commands, especially one that I used a lot in A2003 shortcut menus, the "Filter" with a blank space to enter whatever you wished, including wild cars plus "and" and "or".
Code:
Option Compare DatabaseOption Explicit
'Based on https://docs.microsoft.com/en-us/office/vba/access/concepts/miscellaneous/create-a-shortcut-menu-for-a-form-form-control-or-report
Sub CreateShortcutMenuWithGroups()
Dim cmbRightClick As Office.CommandBar
' Create the shortcut menu.
Set cmbRightClick = CommandBars.Add("cmdFormFiltering", msoBarPopup, False, True)
With cmbRightClick
' Add the Find command.
.Controls.Add msoControlButton, 141, , , True
' Add the copy command.
.Controls.Add(msoControlButton, 19, , , True).BeginGroup = True
' Add the paste command.
.Controls.Add msoControlButton, 22, , , True
' Start a new grouping and add the Sort Ascending command.
.Controls.Add(msoControlButton, 210, , , True).BeginGroup = True
' Add the Sort Descending command.
.Controls.Add msoControlButton, 211, , , True
' Start a new grouping and add the Remove Filer/Sort command.
.Controls.Add(msoControlButton, 605, , , True).BeginGroup = True
' Add the Filter by Selection command.
.Controls.Add(msoControlButton, 640, , , True).BeginGroup = True
' Add the Filter Excluding Selection command.
.Controls.Add msoControlButton, 3017, , , True
End With
Set cmbRightClick = Nothing
End Sub
I've tried Micron's code he researched in post #11 in this link: https://www.accessforums.net/showthread.php?t=68045; this was the only hit I got that came close! Unfortunately, after waiting about 15 to 20 minutes for it to run on Excel 2016, it gave me the codes but just the picture of the command.
----------
Also, quick question on removing a sort. Using the menu I generated above, I have sorted, but not used filters, on the portion of a form view below. The Remove Filter/Sort command is not enabled. It is enabled when I apply a filter. Is there any way to remove the sort with a shortcut menu command and go back to whatever the sort is on the SQL? I'm not sure how to apply the VBA set me.OrderByOn = False and me.OrderBy = "" in a post Access 2003 world. Sorry, I'm having extreme difficulty with images.
Thank you in advance,
--
Tim
PLEASE IGNORE THESE IMAGES FOLLOWING - I COULD NOT GET RID OF THEM AND THE FORUM WOULD NOT ALLOW ME TO DELETE THIS POST TO SDTART AGAIN
SORRY FOR THE CONFUSION