Results 1 to 3 of 3

Thread: Passing Recordsets

  1. #1

    Thread Starter
    Addicted Member cbond's Avatar
    Join Date
    Apr 2001
    Location
    AZ - USA
    Posts
    148

    Passing Recordsets

    Can any one tell me how to pass an open Recordset as a parameter? I have tried the following...

    private sub SUB1()
    'dim and open a rs called RS1

    bResult = MyFunction(RS1)

    'close recordset and move on

    end sub

    Public MyFunction(ByVal RS2 as ADODB.Recordset) as Boolean
    RS2.open
    'do something with the recordset
    RS2.close
    MyFunction = True
    End Function

    The RS2.Open fails to execute. If I move the call below the close recordset in SUB1 it works just fine. I have tried passing it ByVal and ByRef.

    Any assistance would be appreciated!!

  2. #2
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    It fails when you try to open a recordset that is already open. You
    open it in sub1, pass it to myFunction, then inappropriately you're opening it again with RS2.Open so remove that line.

    Ralph

  3. #3

    Thread Starter
    Addicted Member cbond's Avatar
    Join Date
    Apr 2001
    Location
    AZ - USA
    Posts
    148

    Talking

    Thank you very much... it was too obvious and simple of a solution!!

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