OpenRecordset - Run-time error '13'

D

DianePDavies

With reference to Microsoft DAO 3.6 Object Library and the following code

Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb
Set dbs = dbs.OpenRecordset("DHTS")

the code fails in the last statement with "Type mismatch" and Run-time error
13.

DHTS is a table in my database. I have identical code - but with different
table name - running other places - and I have had this happen other places
as well. What's the reason...?
 
O

Ofer

You set the database as Recordset
Set dbs = dbs.OpenRecordset("DHTS")

change it to
Set rst = dbs.OpenRecordset("DHTS")
 
K

Ken Snell \(MVP\)

I assume you're running ACCESS 2000 or 2002 or 2003. In those versions, the
ADO library has higher priority than DAO (unless you've changed it
manually), and thus the Dim rst As Recordset step goes to the ADO library
and not the DAO library.

Disambiguate the dim statement:

Dim rst As DAO.Recordset
 
D

DianePDavies

so embarassing.... this solved this issue. I was just blinded by the fact
that sometimes I really do get this error.
 

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