Why is this a type mismatch error

R

Robert Solomon

Hi. I am trying to copy code from an Access 97 database into an Access
2002 database.

Private Sub Form_Open(Cancel As Integer)
Dim rst As Recordset, lastcnt As Integer

Set rst = Me.RecordsetClone <-- error occurs at this line

rst.MoveLast
lastcnt = rst.RecordCount

Set rst = Nothing

DoCmd.GoToRecord acForm, "Masterform", acGoTo, lastcnt - 6
End Sub

I am getting a type mismatch at the Set rst = Me.RecordsetClone
statement. Searching the help files give me examples that look exactly
like what I'm doing. So why am I getting this error?

Thanks,
Rob
 
C

Cheryl Fischer

Me.RecordsetClone uses DAO, so you will need to have a reference set to the
Microsoft DAO 3.6 Object Library. Then, to dis-ambiguate your Recordset
declaration from an ADO recordset, declare it as follows:

Dim rst as DAO.Recordset
 
R

Robert Solomon

I need more instruction. How do I create a reference set to the DAO 3.6
Object library? Just adding the Dim sttmnt you suggested keeps crashing
Access.

Thanks for your prompt help
Rob
 
C

Cheryl Fischer

Open any code module by pressing ALT-F11. Then, from the VB menu, select
Tools|References. Scroll through the available references until you find
the Microsoft DAO 3.6 Object Library. Click the checkbox to the left of
the library name, then click OK.
 

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

Similar Threads


Top