Max Wanadoo
max.wanadoo at gmail.com
Sat Aug 8 03:18:05 CDT 2009
Hello Stuart, Well, I guess it goes to show that people attack/approach tasks in many different ways. I frequently pass recordsets to functions. For Example, I have a function which sends out emails, the data source comes from a filtered recordset that the user is working on/changing all the time. When the user is happy, they press the Send Emails button, the function is called with the recordset as the parameter. Regardless of where the recordset is derived (the above is just one example), the function does the same thing and can be akin to a Class without any of the class overheads (ahem!). It is, of course, what public function are there to do. Example: Public function pfSendEmails(rst as dao.recordset) as Boolean. With rst Code End with End function That is just one example. There are many others where I pass, typically, recordsets but could be queries (as recordsets) to a function/sub. AND, I hardly ever us Classes - purely because I believe they are an extra overhead to set up a class which is there unnecessarily. But that is another topic which has been beaten to death!! Max -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: 07 August 2009 23:44 To: Access Developers discussion and problem solving Subject: Re: [AccessD] OpenRecordSet question In 16 years of continuously developing complex Access applications, I've never had the need to pass a recordset or a field between functions - but thanks for the tip. I'll bear it in mind if I ever do come across the need. (Guess it's because I don't use classes much <g>) -- Stuart On 7 Aug 2009 at 18:33, jwcolby wrote: > Unfortunately that doesn't always work. If RS loses scope the value of RS "goes away". Inside of > the same function this will always work, but if you try to pass the recordset off to another > function, or a field off to another function, then things fail to work as you expect. > > I had enough run-ins with this that I decided just to bite the bullet and do the dim db statement as > a matter of habit. > > John W. Colby > www.ColbyConsulting.com > > > Stuart McLachlan wrote: > > As a matter of style, I never bother to Dim db. > > > > I just use: > > Dim rs as DAO.Recordset > > Set rs = Currentdb.OpenRecordset("myQuery") > > > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com