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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function = recordset value 2

Status
Not open for further replies.

imarosel

Technical User
Jun 23, 2005
149
US
Maybe what I'm trying to do is crazy. I want a function that does some of my recordset work that can be called from my sub routines in my program. I'd pass in the table name and the function would = the recordset.

private sub blah
'get an error here for invalid use of property
returnedrecordset = recordsetwork("Table Name")
end sub

Function recordsetwork(tabletosee As String)

Dim dbMyDB As Database
Dim rsMyRS As Recordset

Set dbMyDB = CurrentDb
Set rsMyRS = dbMyDB.OpenRecordset(tabletosee, dbOpenDynaset)

If Not rsMyRS.EOF Then rsMyRS.MoveFirst

Set recordsetwork = rsMyRS

End Function
 
It's not crazy at all, it's common in fact. The only change I would make is in your function definition to tell it explicitly what it's returning (i.e. a recordset):

Code:
Function recordsetwork(tabletosee As String) [COLOR=red]As Recordset[/color]

Are you currently getting any errors?
 
And furthermore:
[!]Set [/!]returnedrecordset = recordsetwork("Table Name")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ey gads, I missed that one PHV!

Guess I've been doing too much C# lately, I got used to not using "Set".
 
just read this, awesome...awesome...awesome. Nice to know I'm not crazy. Now how do I build a robot to go to meetings for me so I can free myself up to develop hack together some code?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top