Type Mismatch (error 13) with recordsetclone and form

D

DC Hendrickson

I am an intermediate level VBA programmer using
WindowsXPPro and ACCESS2002. After six weeks I am getting
back to the programming project - so a little rusty.

I am trying to manipulate data in a form by use of the
recordsetclone. But I cannot get past simply assigning
the recordsetclone to a variable inside the procedure.

The scenario is thus:

The cursor enters a control in a subform which causes a
pop up form to open. A selection is made from the data in
the pop up form and a command button on the pop up form
is clicked to update the subform with that chosen data.

The code is located in the form module of a pop up form,
the ADODB and ADOX references are set.

The on_click event is as follows:

Private Sub cmdOK_Click()
Dim rst As ADODB.Recordset
Dim frm As Form

Set frm = Forms!mainform!subform!subsubform.Form
Set rst = frm.RecordsetClone
End Sub

The code causes the "Type Mismatch (error 13)" error upon
execution of the "set rst ..." line. Via the watch window
and a debug.print frm.name entry, the variable frm
appears to be set correctly.

Also, if I change the declaration of the rst variable to
OBJECT, I do not get the error. But if I do this, then
later on in the code an "rst.find" line causes an error
and tells me that this method is not available.

Any insite would be greatly appreciated.

Thanks, Daen
 
J

John Vinson

I am trying to manipulate data in a form by use of the
recordsetclone. But I cannot get past simply assigning
the recordsetclone to a variable inside the procedure.

A Form's RecordsetClone property is a DAO recordset, and you're trying
to set it to an ADODB recordset. Both data models have Recordset
objects but they are DIFFERENT recordset objects!

Try using Me.Recordset.Clone instead: a Form has an ADO Recordset
property upon which you can use the Clone method.
 
D

DC Hendrickson

Thanks John,

About the time you answer arrived I found concuring
information. The book I am using (which shows examples by
modifying the Northwind DB) subtly modified a Project
(*.adp) instead a database (*.mdb). All other examples to
this point had been with a *.mdb file.

There is a "fine print" note that says:

"The Form.RecordsetClone property in Access database
returns a DAO recordset object. The same property in an
Access project returns and ADO recordset object."

Thanks for the help and now I can work around the
speedbump.
 

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