Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DAO, recordset 'Type mismatch error 13"

Status
Not open for further replies.

ALSav

Technical User
Feb 21, 2001
66
GB
Can anyone tell me why I'm getting a type mismatch error with the following code. I have a form with a DAO control and patient_numbers is the name of a table in the database but the error arises with the Set rs = db....etc line.


Option Explicit

Dim db As Database
Dim rs As Recordset

Private Sub Form_Load()

Set db = OpenDatabase("H:\My Documents\PatientNumbers\patientNumbers.mdb")
Set rs = db.OpenRecordset("patient_numbers")

End Sub
 
Hi

My first guess would be to try the following line:
Set rs = db.TableDefs("patient_numbers").OpenRecordset
in place of the one you have now.

When you say you have a DAO control on your form - do you mean a Data Control? If so try clicking on the data control and make sure the RecordSetType is on 0 - Table and that the DefaultType is on 2 - Jet. I don't think it's that but you never know....

Kate
 
Hello - me again

Just a thought but on the line

Dim db as database

it doesn't say

Dim db as Data

does it - because I've just generated the same error as you. It's easy to do because if you don't type Database in full VB "helpfully" inserts Data instead.

Kate
 
I've had this problem for 3 weeks, but I have finally got it. Make reference to the DAO 3.6 object library and move its priority up as much as you can and it should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top