CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Class Modules

  1. #1
    Join Date
    Jul 2000
    Posts
    124

    Class Modules

    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


  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Class Modules

    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
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured