I have a button on a form that opens a small shortcut menu. I would like the menu to be anchored to the bottom of the control so that it always appears in the same spot, instead of wherever the cursor is. Basically I want it to work similarly to the buttons at the top of this forum, like under "Quick Links", the menu starting with "Unanswered Threads" is anchored to the bottom left corner of the "Quick Links" button.
The following is the code for the menu:
Code:
Sub SortPopupMenu()
Dim SortMenu As CommandBar
Dim SortBy As CommandBarControl
Set SortMenu = CommandBars.Add("", msoBarPopup, , True)
Set SortBy = SortMenu.Controls.Add: SortBy.Caption = "Product Type": SortBy.OnAction = "SortByProduct"
Set SortBy = SortMenu.Controls.Add: SortBy.Caption = "Strain Name": SortBy.OnAction = "SortByStrain"
Set SortBy = SortMenu.Controls.Add: SortBy.Caption = "Order Entered": SortBy.OnAction = "SortByItem"
Set SortBy = SortMenu.Controls.Add: SortBy.Caption = "Custom Sort": SortBy.OnAction = "SortByCustom"
SortMenu.ShowPopup
End Sub
Sub SortByProduct()
Screen.ActiveReport.OrderBy = "[ProdType]"
Screen.ActiveReport.OrderByOn = True
End Sub
Sub SortByStrain()
Screen.ActiveReport.OrderBy = "[StrainName]"
Screen.ActiveReport.OrderByOn = True
End Sub
Sub SortByItem()
Screen.ActiveReport.OrderBy = "[InfoID]"
Screen.ActiveReport.OrderByOn = True
End Sub
Sub SortByCustom()
Screen.ActiveReport.OrderBy = "[Sort]"
Screen.ActiveReport.OrderByOn = True
End Sub
Then the code for the form control:
Code:
Private Sub Command246_Click()
SortPopupMenu
End Sub