Hi all.
I wish to call a recordset from a function.
Ive tried the following approach,
--------------------------------------------------------
Function PassRS() As Recordset
Dim db As Database
Dim rs As Recordset
Dim myQdf As QueryDef
Dim mySql As String
mySql = ".............m y sql............ ..."
Set db = CurrentDb
Set myQdf = db.CreateQueryD ef("")
myQdf.SQL = mySql
Set db = Nothing
Set PassRS = myQdf.OpenRecor dset()
End Function
--------------------------------------------------------
Then i call it like this,
--------------------------------------------------------
Private Sub Command1_Click( )
Call PassRS
With PassRS
.MoveLast
Debug.Print "count " & .RecordCount
End With
End Sub
----------------------------------------------------------
And its seems to work. But how do I destroy the recordset object, and the
qryDef object when i'm done with it?
Thanks in advance for any advice.
Gerry Abbott
I wish to call a recordset from a function.
Ive tried the following approach,
--------------------------------------------------------
Function PassRS() As Recordset
Dim db As Database
Dim rs As Recordset
Dim myQdf As QueryDef
Dim mySql As String
mySql = ".............m y sql............ ..."
Set db = CurrentDb
Set myQdf = db.CreateQueryD ef("")
myQdf.SQL = mySql
Set db = Nothing
Set PassRS = myQdf.OpenRecor dset()
End Function
--------------------------------------------------------
Then i call it like this,
--------------------------------------------------------
Private Sub Command1_Click( )
Call PassRS
With PassRS
.MoveLast
Debug.Print "count " & .RecordCount
End With
End Sub
----------------------------------------------------------
And its seems to work. But how do I destroy the recordset object, and the
qryDef object when i'm done with it?
Thanks in advance for any advice.
Gerry Abbott
Comment