type mismatch

  • Thread starter Thread starter thersitz
  • Start date Start date
T

thersitz

Hi,

Have an access2003 db with references to both DAO and ADO added. I try this
code in the immediate window of a form module and get a run-time error 13,
type mismatch.


Private Sub cmdRecordset_Click()
Dim rst As ADODB.Recordset
Set rst = Me.RecordsetClone
rst.MoveFirst
Do
Debug.Print rst!lastName
rst.MoveNext
Loop Until rst.EOF
End Sub


Does this only work with an adp file?
thanks
 
Hi,

Have an access2003 db with references to both DAO and ADO added. I try this
code in the immediate window of a form module and get a run-time error 13,
type mismatch.


Private Sub cmdRecordset_Click()
Dim rst As ADODB.Recordset
Set rst = Me.RecordsetClone
rst.MoveFirst
Do
Debug.Print rst!lastName
rst.MoveNext
Loop Until rst.EOF
End Sub


Does this only work with an adp file?

A Form has a RecordsetClone property - but it's a DAO recordset, not
an ADODB recordset.

Try including the DAO 3.6 object library and Dim'ing rst as
DAO.Recordset; or use Recordset.Clone (with a period) to grab the
ADODB object.

John W. Vinson[MVP]
 
Thanks John.

Well the people who wrote this book must have there head scewed on wrong,
because their syntax is just as I typed it -- the only difference being that
I am attempting it in a mdb file an their example uses an adp.

I do have the DAO library referenced and it does work when I switch to
DAO.Recordset

I am going to try the Recordset.Clone syntax and see what happens.
 
No, the mdb didn't care for the Me.Recordset.Clone syntax

same type mismatch error.

I looked at the code in the adp sample file that comes with the book and it
is written just as I displayed in the example. So it doesn't like that ADO
code in the mdb.
 
I looked at the code in the adp sample file that comes with the book and it
is written just as I displayed in the example. So it doesn't like that ADO
code in the mdb.

Do you have Microsoft Access Data Objects in the References list?

John W. Vinson[MVP]
 
Back
Top