Results 1 to 7 of 7
  1. #1
    Join Date
    May 2010
    Posts
    67

    Unanswered: Passing a recordset object to a sub routine

    Hello,

    I would like to pass a recordset object when calling a subroutine. The subroutine will move the recordset data to the form.

    I tried coding the following(which is not allowed):
    call move_data_to_form(rs1 as recordset)

    Can I pass a recordset object to a called subroutine?

    Thank you in advance for your help!

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Sure; the "As Recordset" part would be part of the function, like:

    Public Function PopulateLocalRes(ByRef rst As ADODB.Recordset)

    and it's called like so:

    PopulateLocalRes rst

    If you use "Call", the argument(s) must be enclosed in parentheses.
    Paul

  3. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I should add that the recordset variable probably has to be declared in a standard module.
    Paul

  4. #4
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by eva.thaeh View Post
    Hello,

    I would like to pass a recordset object when calling a subroutine. The subroutine will move the recordset data to the form.

    I tried coding the following(which is not allowed):
    call move_data_to_form(rs1 as recordset)

    Can I pass a recordset object to a called subroutine?

    Thank you in advance for your help!
    Greetings eva.thaeh,

    Are you using an ADO recordset?

    If we understand what you need, hopefully we can help you find an Access solution. Would you please explain what you are wanting to do.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  5. #5
    Join Date
    May 2010
    Posts
    67
    Hi HiTechCoach

    Yes, I am using a ADO recordset.

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    So is the issue resolved?
    Paul

  7. #7
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by eva.thaeh View Post
    Hi HiTechCoach

    Yes, I am using a ADO recordset.
    This may help:

    Bound form to ADO recordset keeping data from SQL Server
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

Posting Permissions

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