Type Mismatch On Setting Recordset Object Variable

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)
 
D

Douglas J. Steele

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
 
R

Robert Vivian

You are quite correct. I am running Access 2000. Made your suggested change
and it is working ok. Thanks very much.
 

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