PDA

Click to See Complete Forum and Search --> : returning recordsets?


lenin
Aug 23rd, 1999, 03:30 PM
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.

preeti
Aug 23rd, 1999, 07:03 PM
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