Type Mismatch on a Set OpenRecordset

  • Thread starter Thread starter Robin Hughes
  • Start date Start date
R

Robin Hughes

I am running Access 2002 and am trying to open a recordset
on a table I built using a make table query. I get a type
mismatch error everytime I try and run the Set statement.
I have tried every valid Open type I see listed for a
recordset and get this message every one of them. I have
used this statement in other 97 version databases that
have been converted to 2002 and it has worked just fine.
Do you have any idea what I'm doing wrong.

Dim dbs AS Database, rstCheck AS Recordset
Set dbs = CurrentDb
Set rstCheck = dbs.OpenRecordset("tblCheck",dbOpenDynaset)
 
Since it's not failing on the Database declaration or the CurrentDb
statement, you've obviously add a reference to DAO. However, it looks as
though you didn't remove the reference to ADO while you were at it.

If 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 rstCheck as DAO.Recordset (to guarantee an ADO recordset, you'd use
Dim rstCheck 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