Results 1 to 2 of 2

Thread: How to pass recordset name as recordset to a function ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Location
    Bombay,India
    Posts
    10

    Post

    I need to operate on various recordsets.

    rsShift1, rsShift2, rsShift3 are 3 Global recordsets which i need to update.

    ---------------------------------------------------------------------
    For i = 1 To No_of_Shifts
    STR = "FIRST"
    s = "rsShift" & i ' If i do it this way 's' becomes a string 'ERROR'
    Call Store_data(s, STR) ' Here s should be a recordset
    ........
    ........
    Next
    ----------------------------------------------------------------------

    Public Function Store_data(TableName As Recordset, Last_Val As String)

    With TableName
    ...........
    For i = 1 To no_of_tags
    ............
    ...........
    next
    ..........
    End With

    End Function
    ----------------------------------------------------------------------

    How do i pass the names of the recordsets to Store_data as recordsets ?

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Posts
    82

    Post

    Hi,

    Try putting your recordsets in a collection then reference the recordsets from the collection:

    Private colRecordsets As New Collection
    Private rs1 As DAO.Recordset
    Private rs2 As DAO.Recordset
    Private rs3 As DAO.Recordset

    Private Sub test(tablename As DAO.Recordset)
    MsgBox "it worked"
    End Sub

    Private Sub Command1_Click()
    Dim tmprs As DAO.Recordset

    For Each tmprs In colRecordsets
    test tmprs
    Next tmprs
    End Sub

    Private Sub Form_Load()

    With colRecordsets
    .Add rs1
    .Add rs2
    .Add rs3
    End With
    End Sub

    The recordsets do not need to be DAO recordsets.

    Hope this helps,
    Preeti

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