Run Time error 13 - Type mismatch error

M

Mark Wipf

Why oh why do I get a type mismatch error in the following
code:

Private Sub ProcessTransaction_Click()
On Error GoTo Err_ProcessTransaction_Click
Dim db As Database
Dim Members As Recordset
Dim Transactions As Recordset
Dim LastBalance As Recordset

Set db = CurrentDb
Set Members = db.OpenRecordset("Select_Members")
<<Error occurs here
'Select_Members is a select query

Any help is greatly appreciated. Thank you in advance.
 
D

Douglas J. Steele

Let me guess (since you don't say). You're using Access 2000 or newer. Since
the Dim db As Database doesn't raise an error, you've correctly added a
reference to DAO. However, you didn't remove the reference to ADO when you
added the reference to DAO.

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 (which is what
you need for your code), 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
 

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