Below is the code for my cmdOK box in a form called Password. I have a tbl called Security that Password reads the username and password from to validate. In the form I have two text fields called Username and Password and 2 cmd buttons called cmdOK and cmdCancel. In the table there are 3 entries called userID (number field PK), username and password as text fields. My problem is that I am getting a type mismatch error when I click OK. when I debug it points to the line starting with SecTB= Can someone help me please?
*********************************
Private Sub cmdOK_Click()
Dim Curdb As Database, SQLStmt As String, SecTB As Recordset
Set Curdb = CurrentDb() 'If your table and form are in same database other wise change it
SQLStmt = "SELECT * FROM [Security] WHERE [UserName] = '" & Trim("" & Me![txtUsername]) & "'"
SQLStmt = SQLStmt & " AND [Password] = '" & Trim("" & Me![txtPassword]) & "'"
Set SecTB = Curdb.OpenRecordset(SQLStmt, DB_OPEN_DYNASET)
If SecTB.EOF Then
MsgBox "Logon ID or Password not found!", 16, "Incorrect Logon Information"
SecTB.Close
Exit Sub
End If
SecTB.Close
DoCmd.OpenForm "frmExecutives"
DoCmd.Close A_FORM, "Password"
Forms![frmExecutives].SetFocus
End Sub
**********************************
Thank you for all help