• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

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
0
jokro
Asked:
jokro
1 Solution
 
É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
 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now