Context menu Control ID list (1 Viewer)

KitaYama

Well-known member
Local time
Today, 09:53
Joined
Jan 6, 2022
Messages
1,553
Where can I find a list of msoControlButton control IDs?
I'm trying to add the following section to a customized context menu.

1.png


I know the ID for Filter by selection (640), Filter excluding selection (3017), Filter between (10062).
But when I add them the result is not above.

Is there anyway to add exactly the section shown in red to a custom short cut menu for a form?

Thank you.
 

KitaYama

Well-known member
Local time
Today, 09:53
Joined
Jan 6, 2022
Messages
1,553
@theDBguy thanks for helping.
I've seen the excel downlead. But it doesn't cover this section.

I hope you find something that contains the above red rectangle.
thanks.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:53
Joined
Oct 29, 2018
Messages
21,491
@theDBguy thanks for helping.
I've seen the excel downlead. But it doesn't cover this section.

I hope you find something that contains the above red rectangle.
thanks.
Oh, those. You'll have to roll your own on those ones. I know someone who has done that. I'll have to see if it's available.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:53
Joined
May 7, 2009
Messages
19,247
for the "Equals", "Not Equals"

.Controls.Add msoControlButton, 10068
.Controls.Add msoControlButton, 10071
.Controls.Add msoControlButton, 10090
.Controls.Add msoControlButton, 12265
.Controls.Add msoControlButton, 10076
.Controls.Add msoControlButton, 10089
.Controls.Add msoControlButton, 10091
.Controls.Add msoControlButton, 12266
.Controls.Add msoControlButton, 10092
.Controls.Add msoControlButton, 10093
.Controls.Add msoControlButton, 10095
.Controls.Add msoControlButton, 10068
.Controls.Add msoControlButton, 10094

Note that some IDs will only work for "Text" or "Number" field.
so you need to test and create 2 shortcut for text and one for number.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:53
Joined
Feb 19, 2013
Messages
16,629
the buttons Arnel mentions are grouped in the SortSelectionMenu (Policy ID 11759). The SortSelectionMenu is contained within the GroupSortAndFilter menu (Policy ID 11758). The text filters menu is the FilterAdvancedMenu (policy ID 13278).


Control NameControl TypeGroup/Context Menu NameParent ControlPolicy ID
FiltersMenutoggleButtonGroupSortAndFilter
11761​
SortUptoggleButtonGroupSortAndFilter
210​
SortDowntoggleButtonGroupSortAndFilter
211​
SortRemoveAllSortsbuttonGroupSortAndFilter
12267​
SortSelectionMenumenuGroupSortAndFilter
11759​
FilterEqualsSelectionbuttonGroupSortAndFilterSortSelectionMenu
10068​
FilterNotEqualsSelectionbuttonGroupSortAndFilterSortSelectionMenu
10071​
FilterBeginsWithSelectionbuttonGroupSortAndFilterSortSelectionMenu
10090​
FilterDoesNotBeginsWithSelectionbuttonGroupSortAndFilterSortSelectionMenu
12265​
FilterContainsSelectionbuttonGroupSortAndFilterSortSelectionMenu
10076​
FilterDoesNotContainSelectionbuttonGroupSortAndFilterSortSelectionMenu
10089​
FilterEndsWithSelectionbuttonGroupSortAndFilterSortSelectionMenu
10091​
FilterDoesNotEndWithSelectionbuttonGroupSortAndFilterSortSelectionMenu
12266​
FilterBeforeSelectionbuttonGroupSortAndFilterSortSelectionMenu
10092​
FilterAfterSelectionbuttonGroupSortAndFilterSortSelectionMenu
10093​
FilterSmallerThanSelectionbuttonGroupSortAndFilterSortSelectionMenu
10095​
FilterLargerThanSelectionbuttonGroupSortAndFilterSortSelectionMenu
10094​
FilterBetweenbuttonGroupSortAndFilterSortSelectionMenu
10062​
FilterIsSelectedbuttonGroupSortAndFilterSortSelectionMenu
15195​
FilterIsNotSelectedbuttonGroupSortAndFilterSortSelectionMenu
15196​
FilterAdvancedMenumenuGroupSortAndFilter
13278​
FilterClearAllFiltersbuttonGroupSortAndFilterFilterAdvancedMenu
605​
FilterAdvancedByFormbuttonGroupSortAndFilterFilterAdvancedMenu
628​
ApplyFilterbuttonGroupSortAndFilterFilterAdvancedMenu
497​
ServerFilterByFormbuttonGroupSortAndFilterFilterAdvancedMenu
3971​
ServerFilterApplybuttonGroupSortAndFilterFilterAdvancedMenu
3938​
SortAndFilterAdvancedbuttonGroupSortAndFilterFilterAdvancedMenu
499​
LoadFromQuerybuttonGroupSortAndFilterFilterAdvancedMenu
1791​
SaveAsQuerybuttonGroupSortAndFilterFilterAdvancedMenu
1790​
DeleteTabbuttonGroupSortAndFilterFilterAdvancedMenu
2076​
ClearGridbuttonGroupSortAndFilterFilterAdvancedMenu
2087​
CloseDocumentbuttonGroupSortAndFilterFilterAdvancedMenu
14782​
FilterToggleFiltertoggleButtonGroupSortAndFilter
601​
 

KitaYama

Well-known member
Local time
Today, 09:53
Joined
Jan 6, 2022
Messages
1,553
Then in short, we can not add that section in red rectangle to a customized short cut menu.
Am I correct?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:53
Joined
Feb 19, 2013
Messages
16,629
yes and no - you can build something that looks pretty much the same - so far as I know you cannot use an inbuilt menu, only the individual buttons but again you can build your own.

Code:
create your 'top' command bar (msoBarPopup)
add some buttons (msoControlButton - use policyID above to identify which ones)
add a menubar (use msoControlPopup (value=5))
    add buttons to menubar
    add another menubar if you want
          add buttons to this menubar 
add some more buttons if required

Don't have time right now to put an example together but you should get the idea. Here is a link that might help


If you want to use intellisense install the Office XX.X Object library, you can convert to late binding when you are more familiar with it

google 'vba commandbars' for more information
 

KitaYama

Well-known member
Local time
Today, 09:53
Joined
Jan 6, 2022
Messages
1,553
you can build something that looks pretty much the same
Well, that Pretty much the same suits me fine. But unfortunately I failed.

It seems that when I add each menu individually, Access doesn't hide the unnecessary items.
As @arnelgp suggested, I have to create 2 or 3 sets of context menus and set each text box's context menu separately based on data type of the text box. Otherwise Access gives me something like bellow.

Just imagine how many forms and how many textboxes, list boxes, etc....How can I go through all of them and set their context menu one by one?

2022-11-03_10-15-56.png
2022-11-03_10-19-59.png
2022-11-03_11-48-27.png


The third image is when I click an empty place on the form. Because Access doesn't find any textbox under mouse pointer, it shows the context menu this way.


Code:
Set cmbRightClick = CommandBars.Add(cbName, msoBarPopup, False, True)
   
With cmbRightClick
    ' Add Reset Sort
    Set cmbCtl = .Controls.Add(Type:=msoControlButton)
    cmbCtl.Caption = "Reset Sort"
    cmbCtl.OnAction = "ReSortForm"
    cmbCtl.FaceId = 8
       
    ' Add the Find command.
    .Controls.Add msoControlButton, 141, , , 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
       
    .Controls.Add msoControlButton, 10068
    .Controls.Add msoContro    lButton, 10071
    .Controls.Add msoControlButton, 10090
    .Controls.Add msoControlButton, 12265
    .Controls.Add msoControlButton, 10076
    .Controls.Add msoControlButton, 10089
    .Controls.Add msoControlButton, 10091
    .Controls.Add msoControlButton, 12266
    .Controls.Add msoControlButton, 10092
    .Controls.Add msoControlButton, 10093
    .Controls.Add msoControlButton, 10095
    .Controls.Add msoControlButton, 10068
    .Controls.Add msoControlButton, 10094

End With
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 01:53
Joined
Feb 19, 2013
Messages
16,629
In the past I had 3 - one each for text, numbers and dates just used to reinstate basic sort/filter functionality for datasheets in a runtime environment, easy to determine the the datatype based on a fields datatype property. These would be assigned to the appropriate controls on form load.

But sounds like your requirement goes further - so perhaps take a look at the context property?

also look at this link - it's excel, but the concept should be the same

this may be relevant as well

Either way you will need code for the datatype to either select the appropriate commandbar (which can be done in the load event) or set context which would probably need to be set in a controls enter or got focus event. These can all be done in a general module with an event call as discussed in one of your other threads - something like '=setBar([FORM],...)'
 

KitaYama

Well-known member
Local time
Today, 09:53
Joined
Jan 6, 2022
Messages
1,553
Just to be clear, you're suggesting to have a code in onLoad event of each form to run a procedure to set different context menus to different controls based on their data type?

If yes, I think I can do it on my own.
I'm reading provided links now.

Thank you.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:53
Joined
Feb 19, 2013
Messages
16,629
Just to be clear, you're suggesting to have a code in onLoad event of each form to run a procedure to set different context menus to different controls based on their data type?
yes - assuming the form controls needs the menus. Menus for forms will have a different options and datasheets have options to hide the column for example - in my case I wasn't bothered about form menus or datasheet functionality such as hiding/unhiding a column - users can do that with resizing.
 

Users who are viewing this thread

Top Bottom