Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a Property Equal to a Recordset???

Status
Not open for further replies.

jasonp45

Programmer
Joined
Aug 23, 2001
Messages
212
Location
US
I have a custom class I've created, and one of the properties is an ADODB.Recordset. Here's the code:

Private Property Let CharDistCurrFile(ByVal vData As ADODB.Recordset)
Set mCharDistCurrFile = vData
End Property

Private Property Get CharDistCurrFile() As ADODB.Recordset
Set CharDistCurrFile = mCharDistCurrFile
End Property

Standard stuff, right? Now in a sub I Dim a disconnected rs (so scope is only within that sub), create some records, and when I'm done I want to assign the disconnected rs to my CharDistCurrFile property, as in:

CharDistCurrFile = rs

At the end of that sub I destroy the rs with 'rs.Close' and 'Set rs = Nothing'.

Then later in another sub I want to use my CharDistCurrFile property...but it contains nothing! Apparently destroying the rs also empties out my property. How can I assign the entire contents of an rs to a property and have that data persist after I destroy the rs object???
 
Use the recordset's clone method to make a copy for your class.

Chip H.
 
Do Not Close The recordset. Remember when you set Object To Ojbect any methods called will apply to both objects. Just set the second object nothing to free the resources. The first should stay the same

Toyman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top