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