Runtime Error 13 type mismatch

C

Carla B

I have a client with Win XP and Access 2002. He has
created a simple database with one table and some VB
script. When he tries to open a record set, he is getting
the following error: runtime error 13 type mismatch.
Thinking it may have become corrupt, I had the client do
a 'get external data' and import to a new database on hsi
PC and he still got the erro. So he tried the current
database and tried to create a new database on another PC
with Access 2002 and got the same errors. He then took a
database that was created in Access 97 but converted to
Access 2002 and stripped out all its data then copied the
same table and code to that database and it worked. Any
ideas? I have a copy of both databases. Below is a
copy/paste from his table and his module.

TABLE (named MyTable)
ID Text
1 Test 1
2 Test 2

Module (named MyModule)
Option Compare Database


Public Function MyFunction()

Dim dbMine As Database, _
rsMine As Recordset, _
stCrit As String

Set dbMine = CurrentDb

stCrit = "SELECT DISTINCTROW MyTable.* " & _
"FROM MyTable"

Set rsMine = dbMine.OpenRecordset(stCrit)



End Function
 
C

Cheryl Fischer

I believe your client needs to add a reference to the Microsoft DAO 3.6
Object Library. A reference to DAO was added to all databases as a default
in Access 97, but not in Access 2000 or later.

hth,
 
C

Carla B

I thought for sure that was it, but he said he already
had that referenced. Thanks anyway!

Carla
 
D

Dirk Goldgar

Carla B said:
I thought for sure that was it, but he said he already
had that referenced. Thanks anyway!

He probably also needs to qualify his declaration of the Recordset
object, like this:

Dim dbMine As Database, _
rsMine As DAO.Recordset, _
stCrit As String

This is necessary if he added a reference to DAO but didn't remove the
default reference to ADO. Both libraries define a Recordset object, and
they are not compatible, so you have to tell Access which one you mean.
 

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

Similar Threads


Top