jt643
Technical User
- Jun 17, 2003
- 144
The following code is attached to a button's 'on click' where I am wanting to take the 'password' field from a 'databaselogon' form and DLookup my 'tblEmployees' table to make sure that the password entered does in fact correlate with the corresponding 'strEmpName' and 'strEmpPassword' on the 'tblEmployees' table:
'Check Value Of Password In tblEmployees To See If This Matches Value Chosen In UserName
If Me.Password.Value = DLookup("strEmpPassword", "tblEmployees", "[strEmpName]=" & Me.UserName.Value) Then
lngMyEmpID = Me.UserName.Value
'Close Logon Form And Open Splash Screen
sqlcmd = "DELETE from UserTemp WHERE UserName = '" & Forms!DatabaseLogon!UserName & "'"
sqlcmd2 = "INSERT into UserTemp (UserID,UserName) VALUES ('" & UserID & "','" & Forms!DatabaseLogon!UserName & "')"
DoCmd.RunSQL sqlcmd
DoCmd.RunSQL sqlcmd2
DoCmd.Close acForm, "DatabaseLogon", acSaveNo
DoCmd.OpenForm "MainMenu"
Else
MsgBox "Password Invalid! Please Try Again.", vbOKOnly, "Invalid Entry!"
Me.Password.SetFocus
End If
[End Code]
I receive a 'Run-Time Error '2001'' message telling me I have cancelled the previous operation. Thanks, in advance, for any assistance you can provide.
'Check Value Of Password In tblEmployees To See If This Matches Value Chosen In UserName
If Me.Password.Value = DLookup("strEmpPassword", "tblEmployees", "[strEmpName]=" & Me.UserName.Value) Then
lngMyEmpID = Me.UserName.Value
'Close Logon Form And Open Splash Screen
sqlcmd = "DELETE from UserTemp WHERE UserName = '" & Forms!DatabaseLogon!UserName & "'"
sqlcmd2 = "INSERT into UserTemp (UserID,UserName) VALUES ('" & UserID & "','" & Forms!DatabaseLogon!UserName & "')"
DoCmd.RunSQL sqlcmd
DoCmd.RunSQL sqlcmd2
DoCmd.Close acForm, "DatabaseLogon", acSaveNo
DoCmd.OpenForm "MainMenu"
Else
MsgBox "Password Invalid! Please Try Again.", vbOKOnly, "Invalid Entry!"
Me.Password.SetFocus
End If
[End Code]
I receive a 'Run-Time Error '2001'' message telling me I have cancelled the previous operation. Thanks, in advance, for any assistance you can provide.