OpenRecordset - Run-time error '13': Type Mismatch

M

M Skabialka

In Access 2003 I borrowed this code from an earlier datase, but I get a
run-time error.

Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDocument") ' Run-time error
'13': Type Mismatch
'Do stuff....
rs.Close
End If

I checked my references. They are:
Visual Basic for Applications
Microsoft Access 11.0 Oblect Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library

The recordset ends up set to nothing, not to the table "tblDocument".

What am I doing wrong here (my first Access 2003 database from scratch)?

Thanks,
Mich
 
D

Dirk Goldgar

M Skabialka said:
In Access 2003 I borrowed this code from an earlier datase, but I get
a run-time error.

Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDocument") ' Run-time
error '13': Type Mismatch
'Do stuff....
rs.Close
End If

I checked my references. They are:
Visual Basic for Applications
Microsoft Access 11.0 Oblect Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library

The recordset ends up set to nothing, not to the table "tblDocument".

What am I doing wrong here (my first Access 2003 database from
scratch)?

Thanks,
Mich

Huh. With those references set, and with that code, I can see no reason
why you would get a type mismatch error. Are you sure that's the exact
code? Are you sure the error is being raised on that line? This in an
..mdb file, right, not an .adp?
 
M

M Skabialka

This made me suspicious, so I did a compact/repair. Now it is working.
Very strange,

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top