PDA

Click to See Complete Forum and Search --> : Passing A Recordset from a Class


lenin
Feb 23rd, 2000, 04:48 PM
Hello,
Can anyone tell me if it is legitimate to return a recordset from a class? Instinctively you would think this would be possible.
I get "invalid use of property".

Source Code below:

Public Function SelectRecords(queryString As String) As ADODB.Recordset
' * ====================================================================== *
' * Take the query string created on the client interface *
' * and modify sql command in DE, return recordset to client. *
' * ====================================================================== *


Dim lb_return As Boolean
Dim lrs_results As New ADODB.Recordset

'
' Assign the string to existing SQL
'
deUSD.Commands("commForm_QueryCriteria").CommandText = queryString

'
' Check state of Recordset
'
If deUSD.rscommForm_QueryCriteria.State = ADODB.adStateOpen Then
deUSD.rscommForm_QueryCriteria.Close
End If
'
' Call the command with amended SQL statement
'
Call deUSD.commForm_QueryCriteria
Set lrs_results = deUSD.rscommForm_QueryCriteria

MsgBox lrs_results.RecordCount

SelectRecords = lrs_results


End Function

Bigley
Feb 24th, 2000, 07:28 AM
I think what you need to do is simply change your last line of code to


Set SelectRecords = lrs_results