66tigger40
Technical User
Hi
I have a simple User Information Table that based on the login I want to open one of three forms.
The AccessLevel can be either Full, Part or Activity. I have the first part working fine to check the userid against the userinformation tabel to can't get it to open the form based on the AccessLevel - missing something from the code and going round in circles!
Thanks for any pointers!
I have a simple User Information Table that based on the login I want to open one of three forms.
The AccessLevel can be either Full, Part or Activity. I have the first part working fine to check the userid against the userinformation tabel to can't get it to open the form based on the AccessLevel - missing something from the code and going round in circles!
Code:
Private Sub cmdLogin_Click()
Dim UserAccess As Variant
If IsNull(Me.UserLogin) Or Me.UserLogin = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.UserLogin.SetFocus
Exit Sub
End If
If IsNull(Me.UserPassword) Or Me.UserPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.UserPassword.SetFocus
Exit Sub
End If
If Me.UserPassword.Value = DLookup("UserPassword", "tbl_UserInformation", _
"[UserID]=" & Me.UserLogin.Value) Then
UserID = Me.UserLogin.Value
UserAccess = DLookup("[AccessLevel]", "Tbl_UserInformation", "[UserID] =" & Me.UserLogin.Value)
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.UserPassword.SetFocus
Exit Sub
End If
If UserAcess = "Full" Then
DoCmd.Close acForm, "Frm_Login", acSaveNo
DoCmd.OpenForm "Frm_MainMenu"
End If
If UserAccess = "Part" Then
DoCmd.Close acForm, "Frm_Login", acSaveNo
DoCmd.OpenForm "Frm_MainMenuPart"
End If
If UserAccess = "Activity" Then
DoCmd.Close acForm, "Frm_Login", acSaveNo
DoCmd.OpenForm "Frm_MainMenuActivity"
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Thanks for any pointers!