Type Mismatch On Setting Recordset Object Variable

  • Thread starter Thread starter Robert Vivian
  • Start date Start date
R

Robert Vivian

Does anyone have any insight on why I would get a type mismatch when setting
a recordset object variable. The relavany code is:

Dim rstAlert As Recordset
Set rstAlert = dbsAlert.OpenRecordset("Alert", dbOpenDynaset)
 
At a guess, I'd say you're using Access 2000 or 2002, you set a reference to
DAO, but you didn't remove the reference to ADO when you did that.

Recordset is an object in both the ADO and DAO models. Since ADO is higher
up in the list of references, any use of As Recordset will automatically be
assumed to be an ADO recordset. 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 rsCurr as DAO.Recordset (to
guarantee an ADO recordset, you'd use Dim rsCurr 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
 
You are quite correct. I am running Access 2000. Made your suggested change
and it is working ok. Thanks very much.
 
Back
Top