Access_Help
Registered User.
- Local time
- Yesterday, 19:22
- Joined
- Feb 12, 2005
- Messages
- 136
It appears that the script is looking at the first record in the table only as oppose to looping over all records, the first user in the table allows the login but the others don't. Can anyone see any obvious mistake?
'Check to see if data is entered into the UserName combo box
If IsNull(Me.txtUserName) Or Me.txtUserName = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.txtUserName.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "Teachers") And Me.txtUserName.Value = DLookup("Username", "Teachers") And DLookup("Level", "Teachers") = "Admin" Then
'Close logon form and open splash screen
DoCmd.OpenForm "COURSES"
DoCmd.OpenForm "Admin"
DoCmd.OpenForm "Session", , , "[Username] = """ & Me.txtUserName & """"
DoCmd.Close acForm, "Login", acSaveNo
ElseIf Me.txtPassword.Value = DLookup("Password", "Teachers") And Me.txtUserName.Value = DLookup("Username", "Teachers") And DLookup("Level", "Teachers") = "Teacher" Then
'Close logon form and open splash screen
DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm "COURSES"
DoCmd.OpenForm "Session", , , "[Username] = """ & Me.txtUserName & """"
DoCmd.Close acForm, "Login", acSaveNo
Else
MsgBox "Invalid Login. Please check and Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword.SetFocus