Sean O'Halloran
Registered User.
- Local time
- Today, 11:22
- Joined
- Dec 25, 2002
- Messages
- 52
Dear Colleagues,
I'm in over my head. After converting an Access 2003 mdb to 2007 accdb I get a "Type Mismatch" error when trying to login. The error fires when it hits the code in red.
"WorkerIDNumber" is a Primary Key - Autonumber - long integer.
"Password" is a text field.
Any help / advice will be greatly appreciated... - Sean
Private Sub cmdLogin_Click()
On Error GoTo Err_cmdLogin_Click
Dim szPassword As String, szSQL As String
Dim lWorker As Long
Dim iReturn As Integer
Dim db As Database
Dim rstWorker As Recordset
Set db = GetcurrentDB()
szSQL = "SELECT * FROM [tblAPS_Workers] WHERE WorkerIDNumber = " & cboWorker & " AND Password = """ & Trim(txtPassword) & """"
Set rstWorker = db.OpenRecordset(szSQL, dbOpenSnapshot)
If rstWorker.RecordCount = 1 Then
rstWorker.MoveFirst
lWorker = rstWorker!WorkerIDNumber
SetWorker (lWorker)
'Clearing objects
rstWorker.Close
Set rstWorker = Nothing
Set db = Nothing
Set rstWorker = Nothing
DoCmd.Close
DoCmd.OpenForm ("frmMain")
Exit Sub
Else
iAttempt = iAttempt + 1
'If more than 4 logins, abort
If iAttempt = 5 Then
MsgBox ("More than 4 Unsuccessful Attempts, Exiting Access")
rstWorker.Close
Set db = Nothing
Set rstWorker = Nothing
'Exit ACCESS
DoCmd.Quit
Exit Sub
Else
iReturn = MsgBox("Could Not Log In, Please Try Again", , "Log In Failure")
txtPassword.SetFocus
GoTo Exit_cmdLogin_Click
End If
End If
Exit_cmdLogin_Click:
rstWorker.Close
Set db = Nothing
Set rstWorker = Nothing
Exit Sub
Err_cmdLogin_Click:
MsgBox Err.Description
Resume Exit_cmdLogin_Click
End Sub
I'm in over my head. After converting an Access 2003 mdb to 2007 accdb I get a "Type Mismatch" error when trying to login. The error fires when it hits the code in red.
"WorkerIDNumber" is a Primary Key - Autonumber - long integer.
"Password" is a text field.
Any help / advice will be greatly appreciated... - Sean
Private Sub cmdLogin_Click()
On Error GoTo Err_cmdLogin_Click
Dim szPassword As String, szSQL As String
Dim lWorker As Long
Dim iReturn As Integer
Dim db As Database
Dim rstWorker As Recordset
Set db = GetcurrentDB()
szSQL = "SELECT * FROM [tblAPS_Workers] WHERE WorkerIDNumber = " & cboWorker & " AND Password = """ & Trim(txtPassword) & """"
Set rstWorker = db.OpenRecordset(szSQL, dbOpenSnapshot)
If rstWorker.RecordCount = 1 Then
rstWorker.MoveFirst
lWorker = rstWorker!WorkerIDNumber
SetWorker (lWorker)
'Clearing objects
rstWorker.Close
Set rstWorker = Nothing
Set db = Nothing
Set rstWorker = Nothing
DoCmd.Close
DoCmd.OpenForm ("frmMain")
Exit Sub
Else
iAttempt = iAttempt + 1
'If more than 4 logins, abort
If iAttempt = 5 Then
MsgBox ("More than 4 Unsuccessful Attempts, Exiting Access")
rstWorker.Close
Set db = Nothing
Set rstWorker = Nothing
'Exit ACCESS
DoCmd.Quit
Exit Sub
Else
iReturn = MsgBox("Could Not Log In, Please Try Again", , "Log In Failure")
txtPassword.SetFocus
GoTo Exit_cmdLogin_Click
End If
End If
Exit_cmdLogin_Click:
rstWorker.Close
Set db = Nothing
Set rstWorker = Nothing
Exit Sub
Err_cmdLogin_Click:
MsgBox Err.Description
Resume Exit_cmdLogin_Click
End Sub