Customize right click menu (1 Viewer)

Jaye7

Registered User.
Local time
Today, 19:21
Joined
Aug 19, 2014
Messages
205
I have the following script which customizes the right click menu and I love it.

The problem that I am having is that I call the script to add the right click from the form open event and then multiple users can not access the same database.

I use one for forms and then another for reports.

If I manually close the open forms then reopen them then multiple users can use the same database.

If I close and reopen forms with vba the right click still remains making the database not accessible to multiple users.

It is definitely this as when I comment it out from the open event of the forms then everything is OK.

I call the following from the open event of the form as follows

Code:
Public Sub Form_Open(Cancel As Integer)
FormsShortcutMenu
End Sub
The following is stored in a module

Code:
Public Sub FormsShortcutMenu()

Dim cmbRightClick As Office.CommandBar
Dim cmbControl As Office.CommandBarControl

On Error Resume Next

CommandBars("cmdRightClick").Delete
Set cmbRightClick = CommandBars.Add("cmdRightClick", msoBarPopup, False, True) 'NEW COMMANDBAR
 
With cmbRightClick
    
        Set cmbControl = .Controls.Add(msoControlButton, 502, , , True) ' ViewsFormView
        'Set cmbControl = .Controls.Add(msoControlButton, 2952, , , True) ' ViewsDesignView
        
        
        
        Set cmbControl = .Controls.Add(Type:=msoControlButton) 'design view by closing and reopening form so is quicker
        cmbControl.BeginGroup = True                  ' Add a line to separate above group
        cmbControl.Caption = "Design View Quick Load"         ' Add label the user will see
        cmbControl.FaceId = 2952        ' Add label the user will see
        cmbControl.OnAction = "DesignViewFunctionFORM" ' Add the name of a function to call
        
        Set cmbControl = .Controls.Add(Type:=msoControlButton) 'design view by closing and reopening form so is quicker
        cmbControl.BeginGroup = True                  ' Add a line to separate above group
        cmbControl.Caption = "List Report Name"         ' Add label the user will see
        'cmbControl.FaceId = 2952        ' Add label the user will see
        cmbControl.OnAction = "TestingReportName" ' Add the name of a function to call
        
        Set cmbControl = .Controls.Add(Type:=msoControlButton) 'design view by closing and reopening form so is quicker
        cmbControl.BeginGroup = True                  ' Add a line to separate above group
        cmbControl.Caption = "List Form Name"         ' Add label the user will see
        'cmbControl.FaceId = 2952        ' Add label the user will see
        cmbControl.OnAction = "TestingFormName" ' Add the name of a function to call
        
        
        
        Set cmbControl = .Controls.Add(msoControlButton, 12329, , , True) ' ViewsDatasheetView
        Set cmbControl = .Controls.Add(msoControlButton, 5814, , , True) ' ViewsPivotTableView
        Set cmbControl = .Controls.Add(msoControlButton, 5815, , , True) ' ViewsPivotChartView
        Set cmbControl = .Controls.Add(msoControlButton, 21, , , True) ' Cut
        Set cmbControl = .Controls.Add(msoControlButton, 19, , , True) ' Copy
        Set cmbControl = .Controls.Add(msoControlButton, 22, , , True) ' Paste
        Set cmbControl = .Controls.Add(msoControlButton, 222, , , True) ' PropertySheet
        Set cmbControl = .Controls.Add(msoControlButton, 14782, , , True) ' close

End With

    Set cmbControl = Nothing
    Set cmbRightClick = Nothing
        
End Sub
 

stopher

AWF VIP
Local time
Today, 10:21
Joined
Feb 1, 2006
Messages
2,395
Have you split your database into front and back end? Each user should only have their own copy of the front end (the forms). They should not be opening the same copy. They can of course share the back end (data).
 

Jaye7

Registered User.
Local time
Today, 19:21
Joined
Aug 19, 2014
Messages
205
Multiple users are using the same front end, I have no control over them doing this as it is how my boss wants it to be.

This is the only script where I have problems with multiple users using the same front end.

I run all sorts of above scripts like modifying the ribbon etc... and they all work fine, just not this one.
 

stopher

AWF VIP
Local time
Today, 10:21
Joined
Feb 1, 2006
Messages
2,395
Multiple users are using the same front end, I have no control over them doing this as it is how my boss wants it to be.
Ok, but it will cause you problems. I assume you at least have the back end split so when your front end does have a meltdown you at least have the back end data? Also have regular backups?

Assuming you have front and back end split, why not just create a copy of your front end and test with different users using different front ends to see if it solves the problem. Then at least you have an idea of the issue.
 

Jaye7

Registered User.
Local time
Today, 19:21
Joined
Aug 19, 2014
Messages
205
That's exactly how we worked out that it was the right click script causing the problems, I thought that someone may be able to help with the code, as when you manually close forms then someone else can log into the same front end with no problems and then both users can use any forms they want without there being a conflict.
 

Users who are viewing this thread

Top Bottom