I am trying to use to following code to check 2 txt fields against a table. (Security Manager) I keep getting and error 424 object required. Any Ideas?
Thanks!
***********************************************************
Private Sub cmdCheckit_Click()
On Error GoTo ConnectionError
Dim db As Database
Dim rsLogin As Recordset
Dim stDocName As String
Dim stLinkCriteria As String
Dim stMgoto As String
Dim stAppName As String
Set db = DBEngine.OpenDatabase("C:\Track.mdb"
On Error GoTo otherError
If Not db Is Nothing Then
MsgBox "HI", vbCritical, "Login Error"
Set rsLogin = db.OpenRecordset( _
"SELECT * FROM tblLogon WHERE Username = '" & frmLogin.txtUsername & "' AND Password = '" & frmLogin.txtPassword & "'", dbOpenSnapshot)
If rsLogin.EOF Then
MsgBox "Incorrect User Name or Password!", vbCritical, "Login Error"
frmLogin.txtPassword = ""
stMgoto = "mGotoUsername"
DoCmd.RunMacro stMgoto
Else
stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
rsLogin.Close
db.Close
Else
MsgBox "Error Connecting To the database" & vbCrLf & "Please Contact Customer Support"
End If
Exit Sub
ConnectionError:
MsgBox "Error Connecting To the database" & vbCrLf & "Please Contact Customer Support", vbCritical
Exit Sub
otherError:
MsgBox "Error Number " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
Thanks!
***********************************************************
Private Sub cmdCheckit_Click()
On Error GoTo ConnectionError
Dim db As Database
Dim rsLogin As Recordset
Dim stDocName As String
Dim stLinkCriteria As String
Dim stMgoto As String
Dim stAppName As String
Set db = DBEngine.OpenDatabase("C:\Track.mdb"
On Error GoTo otherError
If Not db Is Nothing Then
MsgBox "HI", vbCritical, "Login Error"
Set rsLogin = db.OpenRecordset( _
"SELECT * FROM tblLogon WHERE Username = '" & frmLogin.txtUsername & "' AND Password = '" & frmLogin.txtPassword & "'", dbOpenSnapshot)
If rsLogin.EOF Then
MsgBox "Incorrect User Name or Password!", vbCritical, "Login Error"
frmLogin.txtPassword = ""
stMgoto = "mGotoUsername"
DoCmd.RunMacro stMgoto
Else
stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
rsLogin.Close
db.Close
Else
MsgBox "Error Connecting To the database" & vbCrLf & "Please Contact Customer Support"
End If
Exit Sub
ConnectionError:
MsgBox "Error Connecting To the database" & vbCrLf & "Please Contact Customer Support", vbCritical
Exit Sub
otherError:
MsgBox "Error Number " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub