W
whalesuit
Hi,
I'm working in A2K3, and I'm having a hard time understanding how to
keep an object, say an ADO recordset open after it goes out of scope.
Say I have an object, objHoldsRS that holds a private recordset.
I use a member function FillRS of this object to fill that recordset.
and then
a property get statement to getRS get the RS
Public Function InitializeObjHoldsRS(iRowID as Integer) as objHoldsRS
objInst = new objHoldsRS
objInst.FillRS(iRowID)
Set InitializeObjHoldsRS = objInst
Exit Function
End Function
Now if call this initializer from outside the module it lives in, the
objHoldsRS I have instantiated has been destroyed, evidently because I
went out of its original scope. Likewise, if I pass in the objHoldsRS
to my initialization function, eg:
Public Function InitializeObjHoldsRS(objArg as objHoldsRS, iRowID as
Integer)
Set objArg = new objHoldsRS
objArg.FillRS(iRowID)
Exit Function
End Function
My objHoldsRS object still exists because I haven't gone out of its
original scope, but the Recordset object has been closed because I went
out of that object's scope. Is there any way to avoid this
closing/destroying of objects, or do I have to pass in every object
from the scope where I want to use it?
Thanks,
Eric
I'm working in A2K3, and I'm having a hard time understanding how to
keep an object, say an ADO recordset open after it goes out of scope.
Say I have an object, objHoldsRS that holds a private recordset.
I use a member function FillRS of this object to fill that recordset.
and then
a property get statement to getRS get the RS
Public Function InitializeObjHoldsRS(iRowID as Integer) as objHoldsRS
objInst = new objHoldsRS
objInst.FillRS(iRowID)
Set InitializeObjHoldsRS = objInst
Exit Function
End Function
Now if call this initializer from outside the module it lives in, the
objHoldsRS I have instantiated has been destroyed, evidently because I
went out of its original scope. Likewise, if I pass in the objHoldsRS
to my initialization function, eg:
Public Function InitializeObjHoldsRS(objArg as objHoldsRS, iRowID as
Integer)
Set objArg = new objHoldsRS
objArg.FillRS(iRowID)
Exit Function
End Function
My objHoldsRS object still exists because I haven't gone out of its
original scope, but the Recordset object has been closed because I went
out of that object's scope. Is there any way to avoid this
closing/destroying of objects, or do I have to pass in every object
from the scope where I want to use it?
Thanks,
Eric