troubleshooting Question

Right click popup (cut,copy,paste) Access 2010 runtime

Avatar of martmac
martmacFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft AccessMicrosoft Development
6 Comments1 Solution3055 ViewsLast Modified:
I am distributing an Access 2010 front end in runtime to users. I know that right click menus disappear at runtime, but understand that a command bar popup can be implemented. There are examples of this around and I think I understand the principles, but am struggling to implement and wonder if someone could offer some guidance?

If I can just get a steer, I am sure I can refine and implement it.

I have a number of forms that I want to implement this for and want to setup so that the popup appears only when right clicking text boxes and maybe drop down lists to that I can cop from to etc. The code I have to create the toolbar is below. First of all, I need to know if this is correct, as when I call the function I get  

invalid procedure call or argument. ( I do have a reference by the way to the Office 14 Object Library)

Public Function CreatePopup()
    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
End Function

It is my understanding that I need to call the above at startup to create the popup (but I might be wrong!)

Then there is the question of calling the popup when right clicking on a field

The associated code looks like this, but I can't seem to implement. (not sure where to put it) I realise that in this example it provides a right click option for combo box and also subform. I do need to implement it for a couple of sub forms, so I am interested in that. I am on a really tight schedule to implement this and would really appreciate some guidance.

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
   Exit Sub
       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

Many thanks in advance. Once I understand it and can see it working, I am sure I can refine etc. Would just be good to get it working!!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros