Forms Recordset

R

Raas

I'm using Access 2002. I am trying to set the usage of
the form's recordset so I can manipulate it. I
have "copied" the example, below, from Access 2002 VBA
Handbook, exactly:

Private Sub setRecordset()
Dim rst As ADODB.Recordset, frm As Form
Set frm = Forms!frmavailableLoads
Set rst = frm.RecordsetClone
End Sub
I get a message when reaching the statement "Set rst =
frm.recordsetClone. The message is "Runtime error '13'
Type mismatch.

Can someone help me with the correct coding so I can move
through and display on the form, using recordset method?
 
J

Jonathan Parminter

-----Original Message-----
I'm using Access 2002. I am trying to set the usage of
the form's recordset so I can manipulate it. I
have "copied" the example, below, from Access 2002 VBA
Handbook, exactly:

Private Sub setRecordset()
Dim rst As ADODB.Recordset, frm As Form
Set frm = Forms!frmavailableLoads
Set rst = frm.RecordsetClone
End Sub
I get a message when reaching the statement "Set rst =
frm.recordsetClone. The message is "Runtime error '13'
Type mismatch.

Can someone help me with the correct coding so I can move
through and display on the form, using recordset method?
Hi Raas,
try
Dim rst As NEW ADODB.Recordset

Luck
Jonathan
 
G

Guest

I am not sure what your asking, but is sounds like you
are just trying to set the forms controling table

here is what I do.

Private Sub Form_Open(Cancel As Integer)

Me.RecordSource = "tbl_cities"
End Sub

that is just a small chunck of the code. it is actually
a select case statement that when a certaing case is met,
i will assign a differnet table.
 
R

Raas

I tried the NEW ADODB procedure already and it didn't work
either. I'm trying to be able to move through the table's
recordset with recordset commands and properties. Just
having the recordsource assigned to an object doesn't
help. I need to be able to manipulate the data via VBA
without manual controls on the form having to be
involved. To do that I need the form's recordset to be
equated to an ADODB recordset.

The books I have all say I can do it with this code, but
since it doesn't work I am looking to see what
accomplishes the same thing or what I should do
differently with this code.

Thanks again. Hope someone of you can help.
 
G

Graham R Seach

Raas,

Your problem exists because you are trying to assign a DAO recordset object
to an ADO recordset object. The two don't mix. Try this instead:
Dim rst As DAO.Recordset
Dim frm As Form

Set frm = Forms!frmavailableLoads
Set rst = frm.RecordsetClone

rst.Close
Set rst = Nothing

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
R

Raas

I can understand that. So how do I set my forms recordset
to be ADO?, and how do I test to see what kind of
recordset it is?
 

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