Error 13 - Type mismatch

K

KBDB

I am changing a form in an Access 2000 database that was downloaded from the
Microsoft web site. I have converted it to Access 2007.

I am writing VBA code to support my changes to this form.

This is the beginning of the code for an action button:

Option Compare Database
Option Explicit

Private Sub Command61_Click()
Dim dbs As Database
Dim rst As Recordset
Dim ok As Boolean


On Error GoTo Errorhandle1

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Current Issues", dbOpenDynaset)

...... I get the error 13 when I hit this last statement. Current Issues is
my table.

I have used this fuction so many times that I am really stumped on this one.
Could there be a hidden module that might effect this?

Any ideals you may have would be very helpful.

Thank you,

Kathleen
 
D

Douglas J. Steele

Access 2007 has references set to both ADO and DAO, with ADO being higher in
the sequence than DAO. Recordset is an object in both models, so since ADO
is higher in the sequence,

Dim rst As Recordset

results in rst being declared as an ADO recordset, despite the fact that
you're trying to load it using DAO.

Try changing your declaration to

Dim rst As DAO.Recordset
 
J

James A. Fortune

Douglas said:
Access 2007 has references set to both ADO and DAO, with ADO being higher in
the sequence than DAO. Recordset is an object in both models, so since ADO
is higher in the sequence,

Dim rst As Recordset

results in rst being declared as an ADO recordset, despite the fact that
you're trying to load it using DAO.

Try changing your declaration to

Dim rst As DAO.Recordset

If that resolves the problem then I consider that a conversion bug in
Access 2007. In past versions, when a database containing DAO
references was converted using Convert Database to a version with ADO
higher in the References, IIRC, the DAO references were automatically
resolved properly in the converted copy without having to prepend DAO.
I don't mix ADO and DAO so others might get different results under
those circumstances. Prepending DAO or ADO is a good practice but I
have not found it necessary for converted databases -- so far.

James A. Fortune
(e-mail address removed)
 
D

Douglas J. Steele

James A. Fortune said:
If that resolves the problem then I consider that a conversion bug in
Access 2007. In past versions, when a database containing DAO references
was converted using Convert Database to a version with ADO higher in the
References, IIRC, the DAO references were automatically resolved properly
in the converted copy without having to prepend DAO. I don't mix ADO and
DAO so others might get different results under those circumstances.
Prepending DAO or ADO is a good practice but I have not found it necessary
for converted databases -- so far.

Given that the user previous had Access 2000, which didn't have a reference
to DAO by default, I'm assuming that the OP not only added the reference to
DAO but also removed the reference to ADO. Since he stated that he converted
that database to Access 2007, I'd have to agree that it's a conversion bug:
a reference should not have been added to ADO if one didn't exist
previously. Of course, it's possible that he created a new database and
imported everything from the old one, rather than converting it.

For what it's worth, I always disambiguate. Even in Access 97, where I don't
have a reference to ADO, I still always prepend DAO. Doing that minimizes
the impact of problems with the References collection.
 
B

boblarson

Doug:

I have to say it would appear that your statement about Access 2007 adding
both references is not right. I have created a couple of blank databases to
test and it adds the reference to ACE but no DAO or ADO specific reference.
Before SP1 I remember it adding a reference to DAO, but I can't test it now
because I'm on SP1. I do know that Access 2003 added both as default with
ADO above DAO, but that was the only version I know of that added both.

--
Bob Larson
Access World Forums Administrator

Tutorials at http://www.btabdevelopment.com

__________________________________
 
D

Douglas J. Steele

I can't argue, as I don't have Access 2007 installed on this machine, but I
was sure it had both.

If you've got a reference to ACE, you must be using the accdb format. What
happens if you create an mdb in Access 2007?
 
T

Tony Toews [MVP]

boblarson said:
Doug:

I have to say it would appear that your statement about Access 2007 adding
both references is not right. I have created a couple of blank databases to
test and it adds the reference to ACE but no DAO or ADO specific reference.
Before SP1 I remember it adding a reference to DAO, but I can't test it now
because I'm on SP1. I do know that Access 2003 added both as default with
ADO above DAO, but that was the only version I know of that added both.

I thought it was A2002 with ADO above DAO (or was it A2000 with ADO
above DAO?) and A2003 with DAO above ADO.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
D

Douglas J. Steele

Tony Toews said:
I thought it was A2002 with ADO above DAO (or was it A2000 with ADO
above DAO?) and A2003 with DAO above ADO.

AFAIK, neither 2000 and 2002 include a default reference to DAO (and I don't
have either installed on this machine), but you're right about Access 2003.
I just created a new database, and the default reference to DAO is above the
default reference to ADO.
 

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