Hey all,
I have a main form 'frmLIC' which holds several subforms. I am using a msoBarPopup to hold 'Cut', 'Copy', 'Paste', and 'Hint'.
That code works for some of the subforms on my main form, but does not work for others. And I cannot figure out why.
Can anybody help me?
Please review the attached db. "Right Click" the controls in Person, Address, Phone, or Email and you'll notice a custom Shortcut Menu Bar. If you "Right Click" in Auto Policy, Auto Quote, Home Policy, Home Quote, Action Log, or Notes you will get the standard Shortcut Bar (or none in the Runtime).
The sample form is full of errors that are from a lack of data. Don't worry about them
I have a main form 'frmLIC' which holds several subforms. I am using a msoBarPopup to hold 'Cut', 'Copy', 'Paste', and 'Hint'.
Code:
'Create clipboard menuSub createMenu()
If dbgMode Then On Error GoTo Err_H:
CommandBars("GeneralClipboardMenu").Delete
Dim cmb As CommandBar
Dim ctlCBarButton As CommandBarButton
Set cmb = CommandBars.Add("GeneralClipboardMenu", msoBarPopup, False, False)
Set ctlCBarButton = cmb.Controls.Add(Type:=msoControlButton)
With cmb
.Controls.Add msoControlButton, 21, , , True ' Cut
.Controls.Add msoControlButton, 19, , , True ' Copy
.Controls.Add msoControlButton, 22, , , True ' Paste
End With
With ctlCBarButton
.Caption = "Hint"
.FaceId = 124
.Visible = True
.OnAction = "controlHelp"
End With
Set cmb = Nothing
Exit_H:
Exit Sub
Err_H:
MsgBox "Please write this down:" & vbNewLine & vbNewLine & "1) " & Err.Number & Err.Description & vbNewLine & vbNewLine & "2) " & _
"createMenu", vbCritical
DoCmd.Close acForm, Screen.ActiveForm.Name
Resume Exit_H
End Sub
Sub getRightClick(ByVal actFrm As Form)
If dbgMode Then On Error GoTo Err_H:
Dim ctl As Control
For Each ctl In actFrm.Controls
If TypeOf ctl Is TextBox Then
ctl.ShortcutMenuBar = "GeneralClipboardMenu"
End If
If TypeOf ctl Is ComboBox Then
ctl.ShortcutMenuBar = "GeneralClipboardMenu"
End If
If TypeOf ctl Is CommandButton Then
ctl.ShortcutMenuBar = "GeneralClipboardMenu"
End If
If TypeOf ctl Is SubReport Then
ctl.ShortcutMenuBar = "GeneralClipboardMenu"
End If
Next
Exit_H:
Exit Sub
Err_H:
MsgBox "Please write this down:" & vbNewLine & vbNewLine & "1) " & Err.Number & Err.Description & vbNewLine & vbNewLine & "2) " & _
"createMenu", vbCritical
DoCmd.Close acForm, Screen.ActiveForm.Name
End Sub
That code works for some of the subforms on my main form, but does not work for others. And I cannot figure out why.
Can anybody help me?
Please review the attached db. "Right Click" the controls in Person, Address, Phone, or Email and you'll notice a custom Shortcut Menu Bar. If you "Right Click" in Auto Policy, Auto Quote, Home Policy, Home Quote, Action Log, or Notes you will get the standard Shortcut Bar (or none in the Runtime).
The sample form is full of errors that are from a lack of data. Don't worry about them
Attachments
Last edited: