Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2003 returning RS from function. 1

Status
Not open for further replies.

OnePunchMickey

Programmer
Sep 29, 2003
37
IE
I've got code along these lines:

<snip>

function DoImport()

Dim oCompanyRS As ADODB.Recordset

Set oCompanyRS = GetCompanyList("c:\folder\system")


end function


Function GetCompanyList(FullSystemPath As String) As ADODB.Recordset

cConnectString = "Provider=VFPOLEDB.1;Data Source=" + FullSystemPath + "\system.dbc;" & _
"Mode=ReadWrite|Share Deny None;Password='';Collating Sequence=MACHINE"

Set oConn = CreateObject("ADODB.Connection")

oConn.ConnectionString = cConnectString
oConn.Open

Dim oRS As ADODB.Recordset
Set oRS = New ADODB.Recordset

oRS.Open "SELECT field1 AS Code, field2 AS Name FROM SEQCO", oConn, adOpenStatic

GetCompanyList = oRS

End Function

</snip>

When this is run/compiled I get:

"Invalid use of object" on the GetCompanyList = oRS line.

Help!



***************************************
Need help running those old FoxPro apps on modern systems?
 
If you want to initiate an object, you need to use SET:
Code:
Set GetCompanyList = oRS

Although I'm not sure if this will work anyway - I mean using a recordset as function return value.
If it does not work, you might want to just return the connection string from the function and open the recordset in your main proc..

Good luck,
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top