I have the following code tied to a command button:
I have another piece of code triggered when my userform is loaded, that connects to the database. I have commented out the error handling in the code, and when I run the code, Whenever it encounters the line:
Or the line:
I am getting the following error:
Thank you for your help,
Kevin
Code:
Private Sub cmdOK_Click()
'On Error Resume Next
'On Error GoTo Handler1:
glbLogonMsg = "User ID and/or password is incorrect - please re-enter your login information."
glbUserID = txtUser.Text
glbCurPwd = txtPwd.Text
Set glbADORS1 = New ADODB.Recordset
glbSqlStr1 = "SELECT ID, Number, Name, Password, LastUpdated, FailedLogonAttempts, ExemptEmployee, HasMgrAccess FROM Employee WHERE Number = " & glbUserID
glbADORS1.Open glbSqlStr1, glbADOConn1, adOpenForwardOnly, adLockReadOnly
glbEmployeeID = glbADORS1.Fields("ID")
glbEmployeeName = Trim(glbADORS1.Fields("Name"))
glbFailedLogons = glbADORS1.Fields("FailedLogonAttempts")
glbExempt = glbADORS1.Fields("ExemptEmployee")
glbMgrAccess = glbADORS1.Fields("HasMgrAccess")
If glbADORS1.Fields("Password").Value <> glbCurPwd Then
Set glbADORS2 = New ADODB.Recordset
glbSqlFailure = "UPDATE Employee SET FailedLogonAttempts = (FailedLogonAttempts + 1) WHERE Number = " & glbUserID
glbADORS2.Open SqlFailure, glbADOConn1, adOpenForwardOnly, adLockPessimistic
GoTo Handler1:
Else
Select Case glbFailedLogons
Case 1
MsgBox "There was " & glbFailedLogons & " previous failed login attempt.", vbOKOnly, ""
Case Is > 1
MsgBox "There were " & glbFailedLogons & " previous failed login attempts.", vbOKOnly, ""
Case Else
End Select
Set glbADORS2 = New ADODB.Recordset
glbSqlSuccess = "UPDATE Employee SET FailedLogonAttempts = 0 WHERE Number = " & glbUserID
glbADORS2.Open SqlSuccess, glbADOConn1, adOpenForwardOnly, adLockPessimistic
If (Now - (glbADORS1.Fields("LastUpdated") + 90)) >= 0 Or glbADORS1.Fields("Password") = "system" Or glbADORS1.Fields("Password") = "password" Then
frmNewPwd.Show 1
End If
GoTo Handler2:
End If
Handler1:
MsgBox glbLogonMsg, vbCritical, "Login Incorrect"
txtUser.SetFocus
Exit Sub
Handler2:
frmLogin.Hide
frmTimeClock.Show 1
Set glbADORS2 = Nothing
End Sub
Code:
glbADORS2.Open SqlFailure, glbADOConn1, adOpenForwardOnly, adLockPessimistic
Code:
glbADORS2.Open SqlSuccess, glbADOConn1, adOpenForwardOnly, adLockPessimistic
I know that I am connecting successfully to the database, because my other recordset named glbADORs1 is opening without any errors. It's probably something simple I'm sure, but I've been staring at it too long now and I cannot figure out why - any ideas?Run-time error '3001': Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Thank you for your help,
Kevin