Recordset variable not recognized

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Can anyone tell me why this occurs?

When I set up a recordset in Access and define the recordset object as:
Private rs As Recordset
I get a "Type mismatch error" on this line:
Set rs = db.OpenRecordset("TableName", dbOpenSnapshot)

To my understanding, this should be correct according to the Microsoft Help
documentation. But I have to change the definition to the following before I
can read through the table.
Private rs As Object

Thanks
 
You probably have both ADO & DAO Library in the References and the ADO has
higher priority.

When the rs is declared without qualifier, it is default to the higher
Library and you get ADO Recordset. However, you code needs DAO Recordset
which is not compatible with ADO Recordset. Hence, you get the
type-mismatch error.

Try declaring as:

Dim rs As DAO.Recordset
 
Back
Top