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

  • Thread starter Thread starter M Skabialka
  • Start date Start date
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
 
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?
 
This made me suspicious, so I did a compact/repair. Now it is working.
Very strange,

Thanks
 
Back
Top