How to pass recordset to a function

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
 
D

Dirk Goldgar

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.
 
S

subbu

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
 
L

losmac

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
 
D

Dirk Goldgar

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top