Trying to create a Recordset , I get "Type Mismatch" - what's wro.

G

Guest

I want to create a new DAO Recordset as a Dynaset from an existing attached
table.

Dim rst As Recordset
strSQL = "SELECT ID,FirstName,LastName FROM [My Table]"
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)

The call to OpenRecordset gives me a "Type Mismatch" error. Changing rst to
a Variant returns something that is not a Recordset. Is there some
configuration I should have set up to enable DAO to work?
 
D

Douglas J. Steele

Since you don't say, I'm forced to guess that you're using Access 2000 or
newer, and that you've added a reference to DAO, and that the DAO reference
is lower in the list than the ADO reference. (If you're using Access 2003,
that's the default for the references).

When you have both references, you'll find that you'll need to
"disambiguate" certain declarations, because objects with the same names
exist in the 2 models. For example, to ensure that you get a DAO recordset,
you'll need to use Dim rst as DAO.Recordset (to guarantee an ADO recordset,
you can use Dim rst As ADODB.Recordset)

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset
 

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