Restrict access of Switchboard item without manual user login... (1 Viewer)

avincent61

New member
Local time
Today, 02:17
Joined
Mar 7, 2022
Messages
13
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....

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
 
Solution
Here's a custom switchboard that will give you a place to start. It includes basic security. It assumes everyone logs in, I can give you options for silent login that just gives people view only security. You can create a dummy user and if the user picks login without entering credentials, you silently log him in as the "dummy" user which will have only minimal view security and no update authorization.


I strongly suggest that you remove all the duplicate forms you created and switch to a method like this one.

Users who are viewing this thread

Top Bottom