Is there a better way to code this? I would like it to look and the username and then see what security level they are. If they are a 2 or 3 they have access otherwise access is denied. I would rather have a security value instead of putting actual names.
This is assigned to the Logon Button:
Private Sub LogonBtn_Click()
Dim ID As Long, PW As String, SecurityLevel As String
ID = Nz(DLookup("UserID", "UserT", "Username=""" & Username & """"), 0)
If ID = 0 Then
MsgBox "User not found"
Quit
End If
PW = Nz(DLookup("Password", "UserT", "UserID=" & ID), "")
If PW <> Password Then
MsgBox "Incorrect Password"
Quit
End If
TempVars("Username") = Username.Value
DoCmd.OpenForm "MainMenuF"
DoCmd.Close acForm, Me.Name, acSaveYes
End Sub
I have this on each report:
If TempVars("Username") = "Ken" Or TempVars("Username") = "Staton" Or TempVars("Username") = "Kelly" Then
DoCmd.OpenReport "CombinedRider-Special Chart", acViewReport
Else
MsgBox "Access Denied"
End If