How do I pass a recordset as an argument to a function?
Printable View
How do I pass a recordset as an argument to a function?
I don't, usually. I define my recordsets as globals and use them when/where needed.
Are you using DAO, RDO or ADO? Anyway, in most of the cases, a recordset is an object of the class "Recordset". That means, that in order to pass it to a function, you need first to define the function:
Function Function1(Arg1 As Recordset,...) As ...
Then you need to pass the parameter:
Var1=Function1(RecSet,...)
Hope I helped you!!!
Recordsets to my knowledge can be sent like any other parameter. I use ADO and have used it numberous times.
Example below.
Public Sub NextRecord(records As ADODB.Recordset)
If lb_recordsLoaded Then
If records.EOF Then
MsgBox "Already at last record"
Else
records.MoveNext
Call FillCustomerDetails(records)
End If
Else
MsgBox "No Records to Populate Form"
End If
End Sub