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
jokroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
When calling it in a procedure, don't put parenthesis around your paramater like this:
Module1.foo rst
-or-
Call Module1.foo(rst)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PiNCommented:
It's possible...the error must be somewhere else in your code... are you sure you are passing a none nothing recordset ?
0
wyldemaraisCommented:
hi there
if declaring any variables in declarations remember to make them global!
 
0
rinkelCommented:
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
 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.