Trying to return a recordset from a function

  • Thread starter Corey-g via
  • Start date

Corey-g via

Hi All,

I have a function that I am trying to have use a recordset returned from
another function, but I seem to be losing the data from the recordset.

Currently, Function A declares a recordset variable, then attempts to set the
variable to the returned recordset:
Function A()
dim rs as adodb.recordset
set rs = getrecordset(my_SQLStatement)
end function

Function getrecordset(SQL) as ADODB.recordset
dim rs2 as adodb.recordset
' this function executes the SQL statement and gets the results into rs2
' but when I try to return the recordset, I loose all of the data

set getrecordset = rs2
end function

Am I missing something?



Corey-g via

I think I have found the answer...

I was closing my connection to the db after the "set getrecordset = rs2",
but when I commented it out, I appear to be getting the right data back to
the calling function. This leads to another question though, how can I do
this and close the connection, so that I don't leave it open all the time?


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