recordset oddity

thewiseguy

Registered User.
Local time
Today, 21:23
Joined
Apr 14, 2004
Messages
56
something really odd happened and i have no idea why...

i had some vba with some public recordsets:
Code:
Public rststore, rsttemp, rstfinal As Recordset

later on i have:
Code:
Set rstfinal = CurrentDb.OpenRecordset("tblSTOREFINAL")

everything works fine, but then one day my db went corrupt - crapola!

i started a new one and imported all the forms, tables and queries across and things seemed to be looking good except the above line of code now always brought up the error message RUNTIME ERROR '13' - TYPE MISMATCH. never happened before and couldn't really see what's wrong with it.

then, by chance i tried something and everything works again but i do not know why. when i initially declare the recordsets, i stick in a fake one after rstfinal that never gets used or referenced:

Code:
Public rststore, rsttemp, rstfinal, rstblob As Recordset

somehow, rstblob sitting between rstfinal and the 'As Recordset' bit seems to make it all run smoothly. now if it ain't broke, don't fix it, so i'll leave it there but i would like to know if there is an explanation...
 
twg,

Your first three variables are not of type Recordset,
they are Variants.

The last is a Recordset.


Code:
Public rststore, rsttemp, rstfinal, rstblob As Recordset
          ^         ^        ^         ^
          |         |        |         |
          +---------+--------+   Default Recordset Type (ADO)
                    |
                Variants

Maybe you need:

Dim rststore As DAO.Recordset
Dim rsttemp As DAO.Recordset
Dim rstfinal As DAO.Recordset

And add a specific reference to Microsoft DAO 3.6

Wayne
 
ahhhh - i see
my defence is that someone told me that i could do that... :rolleyes:

just to double check -
i went into tools and references and checked DAO Library 3.6
is that all i need to do...?
 

Users who are viewing this thread

Back
Top Bottom