avincent61
New member
- Local time
- Today, 16:15
- Joined
- Mar 7, 2022
- Messages
- 26
Long story short...Users do not want to manually login to databases, but some objects need to be limited to a handful of users.
I created double the amount of forms to ensure those without explicit access could only View data. In this particular DB, it was easier to break it up this way.
I have a "Personnel" table that includes "UserLogin" & "UserSecurity" fields.
I added hidden, unbound text boxes of the same name to my Switchboard and entered code in Form Load to capture the desired information.
This part works perfectly....
Now, I need to use that captured information to Allow or Deny access to a specific menu of the Switchboard, called "Programs". This sub-Switchboard accesses forms that edit the table data, which only need to be accessed by 5 total users.
I want to put a Public If statement in my Module and simply reference that code to run on the "Programs" button click via the Switchboard Manager.
Below is as far as could get and I don't have any Error Handling added yet either.
I created double the amount of forms to ensure those without explicit access could only View data. In this particular DB, it was easier to break it up this way.
I have a "Personnel" table that includes "UserLogin" & "UserSecurity" fields.
I added hidden, unbound text boxes of the same name to my Switchboard and entered code in Form Load to capture the desired information.
This part works perfectly....
Code:
Private Sub Form_Load()
gblWindowsLoginName = CreateObject("WScript.Network").UserName
Call RibbonsNavPaneHide
Dim User As String
User = Environ("Username")
Me.txtUserLogin = User
Me.txtUserSecurity = DLookup("UserSecurity", "Personnel", "UserLogin='" & Forms!Switchboard!txtUserLogin & "'")
End Sub
Now, I need to use that captured information to Allow or Deny access to a specific menu of the Switchboard, called "Programs". This sub-Switchboard accesses forms that edit the table data, which only need to be accessed by 5 total users.
I want to put a Public If statement in my Module and simply reference that code to run on the "Programs" button click via the Switchboard Manager.
Below is as far as could get and I don't have any Error Handling added yet either.

Code:
Public Function ProgramsMenu()
If txtUserSecurity = 2 Then
'???????????
Else
MsgBox "Please use the Public Menu", vbOKOnly, "Access Denied"
End Function