By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Run-time error '13' Type mismatch

P: 2
I have a table [Users] consist of two fields UserID and Password, and a form with unbounded fields txtUserID and txtPassword.
Im running the below code on MS Access 2000 and Im getting Run-time error '13' Type mismatch,
the line >Set rsT_Users = CurrentDb.OpenRecordset(StrSQL, dbOpenSnapshot)< highlighted in yellow.
the same code worked for me on another DB, I dont know whats wrong could anyone help please.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Dim intLoginFails
  4. ---------------------------------------
  5. Private Sub cmdLogin_Click()
  6. Dim rsUsers As Recordset
  7. Dim StrSQL As String
  8. StrSQL = ""
  9. txtUserID.SetFocus
  10. StrSQL = "Select * From [Users] Where [Users].[UserID]='" & txtUserID & "'"
  11. txtPassword.SetFocus
  12. StrSQL = StrSQL + " AND [Users].[Password]='" & txtPassword & "'"
  13. Set rsUsers = CurrentDb.OpenRecordset(StrSQL, dbOpenSnapshot)
  14. If rsUsers.EOF Then
  15.     intLoginFails = intLoginFails + 1
  16.     If intLoginFails > 3 Then
  17.         MsgBox "You have exceeded then number of attempts"
  18.         DoCmd.Quit
  19.     End If
  20.     MsgBox "Invalid User Name Or Password"
  21. Else
  22.    MsgBox "Correct user Name and Password"
  23.  
  24. End If
  25. End Sub
  26.  
Mar 21 '07 #1
Share this Question
Share on Google+
2 Replies


P: 2
I found it
Dim rsUsers As DAO.Recordset
Mar 21 '07 #2

MMcCarthy
Expert Mod 10K+
P: 14,534
I found it
Dim rsUsers As DAO.Recordset
I'm glad you found it. This happens when the ADO and DAO library are both ticked in the references list. Access doesn't know which to use.

Mary
Mar 21 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.