Results 1 to 2 of 2
  1. #1
    GGCR is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Posts
    6

    Need to set permission to open specific switchboard

    I have been able to successfully create a log in for a multi user database but I now need to add a permissions access to go to a specific switchboard. I have included the code I am presently using and need to know what the next step is. I have in the user table assigned permission levels (Manager & Admin). I would like the sdmin permission to open Main Switch board and manager to open Manager switchboard. Any help would be very appreciated.

    Option Compare Database




    Private intLogAttempt As Integer


    Private Sub cboUser_GotFocus()


    cboUser.Dropdown

    End Sub


    Private Sub cmdExit_Click()


    Response = MsgBox("Do want to close this application?", vbYesNo + vbQuestion, "Quit Application")

    If Response = vbYes Then
    Application.Quit
    End If


    End Sub


    Private Sub cmdLogin_Click()


    Call Login

    End Sub


    Private Sub cmdLogin_Enter()


    Call Login


    End Sub


    Public Sub form_load()

    Dim strUser As String
    strUser = Me.cboUser.Value


    End Sub


    Public Sub Login()

    If IsNull([cboUser]) = True Then 'Check UserName
    MsgBox "Username is required"

    ElseIf IsNull([TxtPassword]) = True Then 'Check Password
    MsgBox "Password is required"

    Else

    'Compare value of txtPassword with the saved Password in tblUser
    If Me.TxtPassword.Value = DLookup("Password", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") Then
    strUser = Me.cboUser.Value 'Set the value of strUser declared as Global Variable


    DoCmd.OpenForm "frmMenu", acNormal, "", "", , acNormal

    Else
    MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Password"
    intLogAttempt = intLogAttempt + 1
    TxtPassword.SetFocus

    End If

    End If

    'Check if the user has 3 wrong log-in attempts and close the application
    If intLogAttempt = 3 Then
    MsgBox "You do not have access to this database.Please contact admin." & vbCrLf & vbCrLf & _
    "Application will exit.", vbCritical, "Restricted Access!"
    Application.Quit
    End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You could use a second DLookup() to get the security level. Personally I'd use a recordset to get both the password and level. Then test the level with an If/Then/Else block or Select/Case depending on how many levels are involved, and open the appropriate form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-27-2012, 03:49 PM
  2. Switchboard button to open txt file
    By Dannat in forum Import/Export Data
    Replies: 17
    Last Post: 01-24-2012, 10:54 AM
  3. Switchboard open form based on function value
    By silverspr in forum Forms
    Replies: 5
    Last Post: 03-10-2011, 02:10 PM
  4. Replies: 3
    Last Post: 01-14-2010, 08:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums