Trying to return a recordset from a function

  • Thread starter Thread starter Corey-g via AccessMonster.com
  • Start date Start date
C

Corey-g via AccessMonster.com

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
okay
' but when I try to return the recordset, I loose all of the data

set getrecordset = rs2
end function

Am I missing something?

TIA,

Corey
 
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?

Corey
 
Back
Top