The CommandBar below isn't taking affect after being compiled and referenced as such in my form's shortcut properties. What I get instead is the default "Cut", "Copy", "Paste" menu. The code is copied from another form I have in another app which works fine, only the "Delete Subscriber" and "Send Today's Menu" options having been added. Since I haven't had an occasion for a shortcut menu for quite awhile, I'm suspecting that I've simply forgotten something. Record Selectors are enabled on the form. The code has been executed. The form has the shortcut menu property set to YES and the name of the Bar selected from the collection's dropdown.
Code:
Option Compare Database
Option Explicit
Public Sub RC14ClickCmdBar()
Dim Bar As Office.CommandBar
On Error Resume Next
CommandBars("R-ClickReg").Delete
On Error GoTo 0
Set Bar = ResetCustomBar("R-ClickReg")
With Bar.Controls.Add(msoControlButton)
.Caption = "Cancel"
.OnAction = "=Cancel(0)"
End With
With Bar.Controls.Add(msoControlButton)
.Caption = "Delete Subscriber"
.OnAction = "=xfrDelReg(0)"
End With
With Bar.Controls.Add(msoControlButton)
.Caption = "Send Today's Menu"
.OnAction = "=xfrDailyMenu(0)"
End With
With Bar.Controls.Add(msoControlButton)
.BeginGroup = True
.Caption = "SELECT ALL"
.OnAction = "=SelectAll(0)"
End With
With Bar.Controls.Add(msoControlButton)
.Caption = "Clear ALL Selections"
.OnAction = "=ClearSelects(0)"
End With
' Debug.Print "Command bar "; Bar.Name; " updated"
End Sub
Private Function ResetCustomBar(BarName As String) As Office.CommandBar
On Error Resume Next
'Delete bar if it exists
CommandBars(BarName).Delete
On Error GoTo 0
Set ResetCustomBar = CommandBars.Add(BarName, msoBarPopup, False)
End Function
Public Function Cancel(dummy As Integer)
End Function
Public Function xfrDelSub(dummy As Integer)
Call Forms("frmSubscribers").DelSub(0)
End Function
Public Function xfrDailyMenu(dummy As Integer)
Call Forms("frmSubscribers").DailyMenu(0)
End Function
Public Function SelectAll(dummy As Integer)
CurrentDb.Execute "UPDATE tblSubscribers SET Selected = '" & ChrW(9658) & "'"
Forms!frmSubscribers.Form.Requery
End Function
Public Function ClearSelects(dummy As Integer)
CurrentDb.Execute "UPDATE tblSubscribers SET Selected = ' '"
Forms!frmSubscribers.Form.Requery
End Function