ecannizzo
March 23rd, 2001, 11:31 AM
I have a form that sets a new class. It then calls one of the classes methods which gets a recordset. In the class I also have another method that performs a movenext on the recordset. The problem is in my click event for the movenext button, I create a instance of the class and then call the movenext function I created. That's when I get an error saying the recordset can't be closed when doing this. But I never closed the recordset!
Please help!
Erica
Johnny101
March 23rd, 2001, 04:05 PM
You are trying to do a movenext on a recordset that has not been created yet. When you declare a variable of MyClass - whether or not you have an existing variable - you will get a new copy. then, when you try to call the movenext of the class - it's acting on ITS recordset object, which is closed because it's new.
To fix this, make a module level variable of your class, and be sure NOT to set it to nothing in between calls to it.
option Explicit
Dim objMine as MyDataClass
Form_Load()
set objMine = new MyDataClass
call objMine.PopulateRS
End Sub
cmdMoveNext_Click()
objMine.MoveNext
End Sub
Form_Unload()
set objMine = nothing
End Sub
something like that should work.
hope this helps,
john
John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org