declaring a recordset object as "object"

B

Brad Pears

In my Access 2000 application I have many dim statments throughout the code
to define a variable called "RS" which is a DAO recordset object.

However, anytime I try to dim it as such, the "set RS =
currentdb.openrecordset(strSQL)" command fails. So, I have resorted to
dimming it as an object and that works just fine... i.e..

"dim RS as Object" INSTEAD OF "dim RS as DAO.Recordset"

Is there any problme with doing this? Will I be incurring additional
overhead as now it has to figure out what type of an object RS actually is
at runtime??

Why may my "dim as dao.recordset" not be working?? I have a reference set
to the DAO 3.6 object library...

Thanks, Brad
 
N

Nick via AccessMonster.com

Brad,

What is the SQL statement you are using to open the recordset, and what error
occurs when the Set statement fails?
It would probably be better to declare as a Recordset instead of Object, just
for the additional overhead you mentioned - it seems like large recordsets
can be slow enough when they are early bound.

Also, on a side note, what are you doing with your recordsets? You said you
declared it several times through your code - you might be better off having
it global or using queries. (But that's not a part of your problem)

-Nick
 
A

Allen Browne

Brad, I agree that it would be good to solve this, rather than hide the
problem by using a less well typed declaration.

Try:
Dim db As DAO.Database
Set db = CurrentDb()
If that fails too, there is a problem with the DAO library, even though
Access is not acknowledging it.

To re-register it:
1. Go to Tools | References, and deselect the Microsoft DAO 3.6 Library.
2. Close Access.
3. Verify the location of dao360.dll.
4. Open a Windows Command prompt.
5. Unregister the DAO library:
regsvr32 /u "c:\program files\common files\microsoft
shared\dao\dao360.dll"
6. Register it again:
regsvr32 "c:\program files\common files\microsoft shared\dao\dao360.dll"
7. Open your database, and select the library again.

General info on references:
http://allenbrowne.com/ser-38.html
 
B

Brad Pears

Hmmmm!! That worked!!! Now I can declare my recordset objects as
DAo.recordsets... Also, the app seems faster too!!)

Thanks for that!!!
 

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