Results 1 to 2 of 2

Thread: returning recordsets?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254

    Post

    hi,
    I seem to have a problem ( lack of intelligence ? ) regarding a small function I have. What I require is to call a function passing in an ado recordset, use the recordset in the function and return a different recordset to the call program.

    e.g.

    Call getCurrentCustomerQueries(lrs_customerID)

    Public Function getCurrentCustomerQueries(customerRecords As ADODB.recordSet) As ADODB.recordSet
    Dim lrs_results As ADODB.recordSet
    If customerRecords.EOF Then
    End
    Else
    Call de.query_no(customerRecords!customer_id, customerRecords!code)
    Set lrs_results = de.rsquery_no
    getCurrentCustomerQueries = lrs_results
    End If
    End Function

    lrs_customer is a normal adodb.recordset and I want to query an SQL Server database for query numbers ( the second recordset ) that are associated with the customer_id, and return them as an adodb.recordset to thecalling program. However I get an "invalid use of property" error message.

    Thanks in advance

    Tony.

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

    Post

    Hi,

    Well since you are returning a value from your function, you need an object to pick up the value when you come back from the function. You can change your call statement to:

    dim newRecordset as New ADODB.Recordset

    set newRecordset = getCurrentCustomerQueries(lrs_customerID)

    change:
    getCurrentCustomerQueries = lrs_results

    to

    set getCurrentCustomerQueries = lrs_results

    And since you are returning an object, you should consider returing some kind of value in all cases where the function exits.

    HTH,

    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