Hi All
I have got some code for a form login screen, I am trying to add multiple account types but really struggling any suggestions would be great, what I want is when the User_Type has been checked it takes the user to the correct for depending on their account type, The below code works fine for two accounts but struggling for multiple accounts.
I have it set like this this:
TABLE (login_tbl)
Forename
Surname
Empl_ID
Login_Pwd
User_Type (Select from: Admin; Standard; View Only; Finance Only)
FORM (frm_Login)
tb_ID - For Empl_ID (In Table)
tb_pwd - For Login_Pwd (In Table)
frm1Btn - Login Button
Code:
Private Sub frm1Btn_Click()
If IsNull(Me.tb_ID) Or IsNull(Me.tb_pwd) Then
MsgBox "You must enter password and login ID.", vbOKOnly + vbInformation, "Required Data"
Me.tb_ID.SetFocus
Exit Sub
End If
If Me.tb_pwd.Value = DLookup("[Login_Pwd]", "login_tbl", "[Empl ID]='" & Me.tb_ID.Value & "'") Then
If DLookup("[User_Type]", "login_tbl", "[Empl ID]='" & Me.tb_ID.Value & "'") = "Admin" Then
DoCmd.openForm "admin_menu"
DoCmd.Close acForm, "login", acSaveNo
Else
DoCmd.openForm "user_menu"
DoCmd.Close acForm, "login", acSaveNo
End If
Else
MsgBox "Password or login ID incorrect. Please Try Again", vbOKOnly + vbExclamation, "Invalid Entry!"
Me.tb_pwd.SetFocus
End If
End Sub