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

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
Back
Top