RecordsetClone

  • Thread starter Thread starter Ken Ivins
  • Start date Start date
K

Ken Ivins

I am trying to use a RecordsetClone to set a recordset and keep getting a
Run Time Error '13': type mismatch.

Dim RS2 As Recordset
Set RS2 = Me.RecordsetClone

The table I am trying to look at has an ID field (auto number, long
integer), one other number field (long integer), one number percentage field
(double), and a text box.

Any ideas where I should look to fix this so I can move on?

Thanks,
Ken Ivins
 
-----Original Message-----
I am trying to use a RecordsetClone to set a recordset and keep getting a
Run Time Error '13': type mismatch.

Dim RS2 As Recordset
Set RS2 = Me.RecordsetClone

The table I am trying to look at has an ID field (auto number, long
integer), one other number field (long integer), one number percentage field
(double), and a text box.

Any ideas where I should look to fix this so I can move on?

Thanks,
Ken Ivins

I had this problem also a few months ago. It lies in the
VBA reference priorities, not anything you would expect
from the error message or controls involved. To fix it:
1. Get into the VBA Editor
2. Go to the Tools menu, choose References
3. Select the Microsoft DAO 3.6 Object Library
4. Move it up as high in the priority list as you can
(third place in my list)
5. You may need to close Access and restart - not sure
 
John,

Wow, not what I expected as the answer, but you were right. This did the
trick. I'm glad it was not me.

Thanks,
Ken Ivins
 
Glad it worked for you. I was as stunned when I discovered this also. It
does make sense once you're aware of it and think about it logically. I got
the solution from a friend who also develops Access applications - he's not
sure where he foudn the solution. I then also found it specifically pointed
out in the book, Access 2002 Desktop Developer's Handbook, by Paul Litwin,
Ken Getz, etc on page 469. (If you're not aware of this book and are a
serious developer, this book is an incredible source of ideas and help.)

John Loewen
 
You also can add DAO. in the Dim statement:

Dim RS2 As DAO.Recordset

That disambiguates the Recordset declaration.
 
That didn't fix it for me when I had a similar problem. Once I moved the DAO
3.6 library up in thr reference priority list, the problem went away. I did
keep the DAO.Recordset syntax also just to specify it clearly.
John Loewen
 
So long as you disambiguate the declaration, the order of priorities in the
references list will not cause a problem. Not sure why you saw that problem
before, but this is how I am using my A2K2 (2K default) program.
 
Back
Top