How to pass a recordset to a function?

DKDiveDude

Registered User.
Local time
Today, 02:10
Joined
Mar 28, 2003
Messages
56
This might seem to be simple to the more advanced of you out there, but I seem to have some problems with this (read: getting errors).

I have a recordset of a table, and I then want to pass the whole recordset (all the fields) to a function where I need to process the data.

Well it actually seems like I'm able to pass the recordset to a function, but then again maybe not, because I get an error when I try to read the first field:

Compile Error:
Method or data member not found

My Function is defined like this:
Private Function MyFunction(rst As DAO.Recordset)

and I try to access a particular field in the recordset (table) like this:
myString=rst.txtSiteName

The recordset is defined like this:
Dim rstDetails As DAO.Recordset

and I open it this way where "Selection" is the SQL string:
Set rstDetails = CurrentDb.OpenRecordset(Selection)

and I call it like this:
strComplete=MyFunction(rstDetails)

What am I doing wrong here?
 
it sounds like your references

open a code module
select tools, references
make sure there is a reference to DAO checked

if there is move it up the list as high as it will go
if there isnt,find the reference in the list and check it and
move it up the list
 
Sorry my mistake here!

If I reference the recordset field like this:

myString=rst![txtSiteName]


instead of this:

myString=rst.txtSiteName

It works.

Thanks
 

Users who are viewing this thread

Back
Top Bottom