Hi,
I am developing an excel(2k) spreadsheet that retrieves data from an Oracle database, and then loads that data into the spreadsheet.
The structure I am after is:
public sub retreiveManager()
...
set rst = getOracleData()
loadSpreadSheet rst
...
end sub
public Function getOracleData() as Recordset
...
Set getOracleData = localRst
Set localRst = Nothing
...
end Function
public sub loadSpreadsheet(rst as RecordSet)
...
with rst
'My trouble appears here
while not .EOF
(do things)
.MoveNext
loop
end with
...
end sub
the trouble occurs when I try to refer to recordset in the functions away from where the recordset is created, in particular loadSpreadSheet(). I can play with the results in the getOracleData function (so it works fine) and use loadSpreadSheet directly from that function, but not elsewhere. When trying to reference the recordset object in the other functions, the error 'Object not valid or no longer set' is trapped. I understand the error itself, but not how to resolve it.
Any help appreciated.
Cheers & thanks
Steve
I am developing an excel(2k) spreadsheet that retrieves data from an Oracle database, and then loads that data into the spreadsheet.
The structure I am after is:
public sub retreiveManager()
...
set rst = getOracleData()
loadSpreadSheet rst
...
end sub
public Function getOracleData() as Recordset
...
Set getOracleData = localRst
Set localRst = Nothing
...
end Function
public sub loadSpreadsheet(rst as RecordSet)
...
with rst
'My trouble appears here
while not .EOF
(do things)
.MoveNext
loop
end with
...
end sub
the trouble occurs when I try to refer to recordset in the functions away from where the recordset is created, in particular loadSpreadSheet(). I can play with the results in the getOracleData function (so it works fine) and use loadSpreadSheet directly from that function, but not elsewhere. When trying to reference the recordset object in the other functions, the error 'Object not valid or no longer set' is trapped. I understand the error itself, but not how to resolve it.
Any help appreciated.
Cheers & thanks
Steve