How to pass recordset to a function

  • Thread starter Thread starter subbu
  • Start date Start date
S

subbu

Hi,
I want to pass ADODB.recodrset as a parameter to a
function.I am getting typemismatch error

Any help in this regard is highly appreciated

subbu
 
subbu said:
Hi,
I want to pass ADODB.recodrset as a parameter to a
function.I am getting typemismatch error

Any help in this regard is highly appreciated

subbu

Make sure both the parameter and the object you're passing are declared
as ADODB.Recordset. If that still gives an error, post your code.
 
Hi,
Here is the code

dim rs as ADODB.RECORDSET

SET RS = conn.execute(ssql)

GenerateExcel(rs) -- I am calling the function

Public Function GenerateExcel(rs As ADODB.Recordset)is the
function
 
Example:

Function DoSomethingWithRecordset(rst as Recordset)
'your code to do something with recordset
End Function

How to pass recordset as parametr to function?

Sub Test()
Dim rst as Recordset
Set rst = CurentDb.OpenRecordset("recodset_name")
DoSomethingWithRecordset rst 'must be the same type
'other instructions
End Sub
 
subbu said:
Hi,
Here is the code

dim rs as ADODB.RECORDSET

SET RS = conn.execute(ssql)

GenerateExcel(rs) -- I am calling the function

Public Function GenerateExcel(rs As ADODB.Recordset)is the
function

Either write

GenerateExcel rs

or

Call GenerateExcel(rs)
 
Back
Top