I am trying to disable the menus for non-admin users. I have done this successfully but the copy/paste functions (by right-clicking in a textbox) do not work. I have tried enabling the Menu Bar, but this still isn't working.
Traditional Control + C and Control + V work fine. It is the right-clicking the doesn't come up. -
If adminRights = True Or userii = "mjdamico" Then 'Set Admin rules
-
For i = 1 To CommandBars.Count
-
CommandBars(i).Enabled = True
-
Next i
-
-
DoCmd.SelectObject acTable, , True
-
DoCmd.SetWarnings True
-
-
Else 'Set non-Admin rules
-
For i = 1 To CommandBars.Count
-
CommandBars(i).Enabled = False
-
Next i
-
-
DoCmd.SelectObject acTable, , True
-
DoCmd.RunCommand acCmdWindowHide
-
DoCmd.ShowToolbar "Menu Bar", acToolbarYes
-
DoCmd.SetWarnings False
-
End If
-
@NeoPa:
I interpret this as a very specific Request, namely:
Disabling ALL Menus for Non-Admin Users NOT (adminRights = True Or userii = "mjdamico"), while at the same time Enabling the Right-Click, Shortcut Menu for Text Boxes. The actual Code should be (not as previoously indicated): -
Dim cmd As CommandBar
-
-
For Each cmd In Application.CommandBars
-
cmd.Enabled = (cmd.Name = "Form View Control" And NOT (adminRights = True Or userii = "mjdamico"))
-
Next
-
13 8927
To Enable/Disable the Right-Click Shortcut Menus for a specific Form, you can modify the Value (True/False) of the ShortCutMenu Property of that Form. In your case: - Me.ShortcutMenu = (adminRights = True Or userii = "mjdamico")
- This Value can be set for all Forms if necessary.
- You can set this Property Globally in your StartUp Database Options (AllowShortcutMenus), but I do believe that once you initially set it, you must exit the DB to take effect from that point on.
NeoPa 32,556
Expert Mod 16PB
I don't know of any way (I suspect there is none) to allow only specified, individual, options from the right-click menu. It is either enabled or not as far as I'm aware.
I have Access 2007 but this worked for 2000. Set a reference to the Microsoft Office 12.0 Object Library. The 12.0 will change depending on version. I believe the function only needs to be run once and the menu will be stored with your database. Set ShortcutMenuBar property of the control to name of command bar. It should be in a drop down list in design view.
Then enable disable as ADezii stated. - Option Compare Database
-
Option Explicit
-
-
Public Function CreateCustomMenus()
-
On Error Resume Next
-
CommandBars("SFDrawing_Dwg").Delete ' not sure if this needed
-
Dim cmbBtn As CommandBarButton
-
Dim cmb As CommandBar
-
-
Set cmb = CommandBars.Add("SFDrawing_Dwg", msoBarPopup, False, False)
-
With cmb
-
.Controls.Add msoControlButton, 210, , , True '210 Sort Ascending
-
.Controls.Add msoControlButton, 211, , , True '211 Sort Descending
-
.Controls.Add msoControlButton, 21, , , True ' Cut
-
.Controls.Add msoControlButton, 19, , , True ' Copy
-
.Controls.Add msoControlButton, 22, , , True ' Paste
-
Set cmbBtn = .Controls.Add(msoControlButton, , , , True)
-
With cmbBtn
-
.Caption = "View Pdf"
-
.OnAction = "=fncOnActinBtn3()"
-
.BeginGroup = True
-
End With
-
End With
-
-
Set cmb = Nothing
-
End Function
-
'21 Cut
-
'19 Copy
-
'22 Paste
-
'
-
'539 New Record
-
'644 Delete Record
-
-
'210 Sort Ascending
-
'211 Sort Descending
-
'640 Filter By Selection
-
'605 Remove Filter / Sort
-
-
'247 page Setup
-
'4 Print
-
'258 Send Email
-
-
-
Public Function fncOnActinBtn3()
-
Dim ctlCurrentControl As control
-
Dim strControlName As String
-
Set ctlCurrentControl = Screen.ActiveControl
-
strControlName = ctlCurrentControl.Name
-
get_spdf_files Nz(ctlCurrentControl.Value, "") 'Function tells operating system to open pdf file
-
End Function
NeoPa 32,556
Expert Mod 16PB
It looks like that flexibility is built into Access (Office generally I suspect) MJ (Thanks due to Hennepin for that illuminating piece of code). Now the problem is that your question is pretty unclear. What (clearly) are you hoping to achieve? You explain what isn't working, but even that is vastly unclear as there is no discernable context within which to make sense of it.
I am trying to get the right-click menu to pop-up when the mouse is right-clicked inside of any textbox (like it normally does). The problem is, I am disabling (or hiding, I am unsure) all of the toolbars for non-admin users. Per my research, I understand that if all of the toolbars are disabled, this also disables the right click menu.
That is why I added this line of code back in to re-enable the right click menus, which was unsuccessful. -
DoCmd.ShowToolbar "Menu Bar", acToolbarYes
-
@damicomj:
The specific Shortcut Menu that you wish to control can be viewed via: - View ==> Toolbars ==> Customize ==> Select Shortcut Menus ==> on Shortcut Menus ==> Form ==> Form View Control
Disable ALL Commandbars except this one, then selectively Enable/Disable it depending on who is Logged On.
----------------------------------------------------------------------------------
The following Code should Enable the Right-Click Shortcut Menu, within the context of a Text Box (Form View Control), only for the Admin User. The Code is easily adaptable for other Users also: - Dim cmd As CommandBar
-
-
For Each cmd In Application.CommandBars
-
cmd.Enabled = (cmd.Name = "Form View Control" And CurrentUser = "Admin")
-
Next
P.S. - I didn't have the time to extensively test this, ergo the reason for the should in BOLD.
ADezii, I got an error on line 1: User-defined type not defined
You need to set a Reference to the Microsoft Office XX.X Object Library: - In Code Window ==> Tools ==> References ==> Select Microsoft Office XX.X Object Library ==> OK
NeoPa 32,556
Expert Mod 16PB
So, you want right-click menus and the main Menu still available, but all the other visible toolbars not to be.
I suspect ADezii's instructions should be enough then. Hennepin mentioned the reference to the Microsoft Office XX.X Object Library in post #4. Let us know how you get on with it.
@NeoPa:
I interpret this as a very specific Request, namely:
Disabling ALL Menus for Non-Admin Users NOT (adminRights = True Or userii = "mjdamico"), while at the same time Enabling the Right-Click, Shortcut Menu for Text Boxes. The actual Code should be (not as previoously indicated): -
Dim cmd As CommandBar
-
-
For Each cmd In Application.CommandBars
-
cmd.Enabled = (cmd.Name = "Form View Control" And NOT (adminRights = True Or userii = "mjdamico"))
-
Next
-
NeoPa 32,556
Expert Mod 16PB
You may be right ADezii. My attempts to get the OP to clarify have been somewhat unsuccessful so far. Your code example seems quite clear though, so hopefully can be manipulated by them to fit whatever their actual requirement is without any trouble.
ADezzi and NeoPa,
My apologies for not being able to clarify the problem. ADezzi's solution has solved the problem for now, until I have the access to fully test. If it wasn't for both of your hard work, I would be stuck in never-never-land.
Thanks again!
@damicomj:
I sure that I can speak for NeoPa as well as for myself in stating that we were both glad to assist you in this matter. One other small point that I would like to make is that you can also Enable/Disable Options within this Shortcut Menu. Suppose that you wanted to disable the Filter By Selection and Filter Excluding Selection Options on the Shortcut Menu when you Right-Click in a Text Box: - With Application.CommandBars("Form View Control")
-
.Controls("Filter By Selection").Enabled = False
-
.Controls("Filter Excluding Selection").Enabled = False
-
End With
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lori3laz |
last post by:
How do you disable the right click>view source option on web pages so people
can't view your coding and copy it? What's the html I need to include in my
website to utilize this feature?
Thank...
|
by: Brian Keating |
last post by:
hi there,
does anyone know how to prevent the context menu on a ToolStripText box from
appearing?
when i right click on the toolstriptextbox i get presented with the system
undo
------
cut...
|
by: Ryan Joseph So |
last post by:
On textboxes when you right click the mouse button a menu will pop-up
with undo,cut,copy,paste,delete,select all. How can i disable the menu
so when i right click on the textbox no menu will...
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard...
|
by: Lloyd Dupont |
last post by:
I'm implementing my own, custom, internationalized text editor.
I'm trying to implement copy/paste right now. Which cause me some trouble.
I'm using .NET 2.0 beta 2 (I have ordered and I'm waiting...
|
by: Mclaren |
last post by:
I have this code that disables all menus and toolbars including the right click functions.
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i
How can i...
|
by: Amar |
last post by:
Hi All,
I am a newbie to PHP and have the task to create a page using PHP where
in that page I need to disable all key operation as well as mouse
operation even also the menu operation that...
|
by: Steve |
last post by:
How do you disable the mouse right click to prevent pop-up window?
Or if I want to have cut/copy/paste on pop-up window use same code as my
custom cut/copy/paste that are triggered by toolstrip...
|
by: jh |
last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a
textbox but can't figure out how to accomplish this for a listbox. Any
help? Thanks.
|
by: Archanak |
last post by:
Hi,
I have a text box and should allow user to type the text but not to allow them to copy/paste or right click.
Here is the code.
<html>
<head>
<meta http-equiv="Content-Type"...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |