jokro
asked on
passing recordset to a function or procedure
Is it possible to pass an ADO-Recordset to a function or a procedure in a class- or standard-module?
Example:
Form1:
---
private rst as ADODB.Recordset
.
.
.
Module1.foo(rst)
---
Module1:
---
Public Sub foo(rst as ADODB.Recordset)
'Do something
End Sub
---
doesn't work (type mismatch)
Any ideas?
Thanks in advance
Jochen
Example:
Form1:
---
private rst as ADODB.Recordset
.
.
.
Module1.foo(rst)
---
Module1:
---
Public Sub foo(rst as ADODB.Recordset)
'Do something
End Sub
---
doesn't work (type mismatch)
Any ideas?
Thanks in advance
Jochen
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's possible...the error must be somewhere else in your code... are you sure you are passing a none nothing recordset ?
hi there
if declaring any variables in declarations remember to make them global!
if declaring any variables in declarations remember to make them global!
What i think is, you needn't set the recordset in private mode! By the way, once you declare the variables for the form in a form, you can use it anywhere within the form even in other modules or functions within the same form. So, what you need here is declare the recordset with "Dim rst as ADODB.Recordset". Once you connect and put data into it, you can access and retrieve data anywhere you like within the same form including the modules and functions in the form. If you want to access the data in another recordset, then declare another recordset and copy the "rst" records to a temp recordset, e.g. Dim TempRst as ADODB.Recordset
set TempRst = rst.Clone
set TempRst = rst.Clone