Could someone please tell me what I am doing wrong in the following statement?
Could someone please tell me what I am doing wrong in the following statement?
Private Sub Form_Load()
If UserLevel = "admin" Then
With Forms("Menu")
Command2.Visible = True
Command2.Visible = True
'or
If UserLevel = "Editor" Then
With Forms("Menu")
Command2.Visible = True
Command2.Visible = True
'or
If UserLevel = "User" Then
With Forms("Menu")
Command2.Visible = False
Command2.Visible = False
End Sub
What is UserLevel?
Why are there duplicate assignments for Command2 in each option?
What exactly do you intend this code to do?
I recommend this Steve Bishop video for Login ideas.
And this one for Managing User Access
Thank you. I will look at those and let you know how it works.
I'm sorry to tell you but almost everything is wrong with your code
1. 3 With ... and no End With
2. 3x If ... and no End If
3. Command2.Visible lines duplicated
The code for Admin and Editor is identical so that can also be simplified
BUT assuming command2 is on the same form as this code, use Me. syntaxCode:Private Sub Form_Load() If UserLevel = "admin" Or UserLevel = "Editor" Then Forms!Menu.Command2.Visible = True ElseIf UserLevel = "User" Then Forms!Menu.Command2.Visible = False End If End Sub
Or simpler stillCode:Private Sub Form_Load() If UserLevel = "admin" Or UserLevel = "Editor" Then Me.Command2.Visible = True ElseIf UserLevel = "User" Then Me.Command2.Visible = False End If End Sub
Code:Private Sub Form_Load() Me.Command2.Visible = True If UserLevel = "User" Then Me.Command2.Visible = False End Sub
Last edited by isladogs; 02-09-2019 at 06:05 PM.
That is awesome. It was so simple. Thank you very much. It is working great now.
The last one. I already had user security set up and an audit trail that was working fine. I just didn't like having an admin page, editor page and user page. Now I can just have one called menu and hide the command buttons based on their security level. Now I am going to look into disabling the quick access commands so no one can tamper with anything. I have it working in 2007 just great. But I am building it in 2007 and then migrating to 2016. And the privacy option still shows up even with a custom ribbon. But I still need to be able to access everything even after disabling the shift key. I probably need to post this in a different thread though.
For some reason, removing parts/all of the File menu has come up repeatedly in the past week or so.
See this link https://www.access-programmers.co.uk...d.php?t=303653 for more information and the other 3 links in that thread that I listed.
You might also find this article on my website useful: http://www.mendipdatasystems.co.uk/i...ity/4594461803
EDIT:
AFAIK the only way to disable the quick access toolbar is to remove it completely. To do that, you have to remove the ribbon completely.
I would be great if you could just remove the customise dropdown on the QAT but I believe that can't be done
That is awesome. Thank you. I will let you know how it works out.