Arthur Fuller
artful at rogers.com
Sat Sep 6 22:20:03 CDT 2003
I suppose I could save them to a table, but so far I don't bother. My biggest concern is run-time evaluation, not preservation between runs. I developed this technique because I needed to "remember" a bunch of variables that are all set on different forms, and then use them elsewhere. To take a trivial example, if you select "Bruce Springsteen in Toronto", that must act as a filter on several other forms, which may or may not be open at the time you select. (Given that I rely heavily on JC's JIT tabs, said forms are often but not always not yet loaded.) Gradually this led me to a system in which I don't rely on any forms being open. Instead I call the statics in SET mode when the user selects something of interest, and then call them again in GET mode when I need them. Typically I call them in SET mode in an AfterUpdate of some control on some page or other. Occasionally it's in the OnCurrent method of a form. I just did one like that today, where there's an unbound form containing a datasheet subform, and on the master form's footer is a button for Delete. The subform's OnCurrent calls CurrentTicketAllocationID() and passes the PK to it. The button interrogates CurrentTicketAllocationID() without a param and obtains the just-set value, then passes it to a sproc that does a sort of cascade-delete but with smarts. It's one line of code to set it and one line of code to get it. HTH, Arthur -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Michael R Mattys Sent: Saturday, September 06, 2003 11:23 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] A2K Reference the dot column property in a query Arthur, Where and when are you initializing these static variables? Do you write them to a table on the close of your database and retrieve them at the opening? (Like a registry hive) Michael R. Mattys www.mattysconsulting.com ----- Original Message ----- From: "Arthur Fuller" <artful at rogers.com> To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> Sent: Saturday, September 06, 2003 2:48 PM Subject: RE: [AccessD] A2K Reference the dot column property in a query > Thanks for the explication, Stuart! > > IMO the coolest thing about statics is that you can eliminate references to > forms. In the AfterUpdate event of some control, you call the static > function and pass the param. Anywhere else you need it, call the func > without a param. I don't like being tied to particular forms being open. I > want to be able to run a query etc. from the debug window anytime I want, > and to set said static func from the debug window anytime I want. Statics > give me this. That's why I love 'em. > > A. > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Rocky Smolin - > Beach Access Software > Sent: Saturday, September 06, 2003 8:23 AM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] A2K Reference the dot column property in a query > > > Oh. That's very cool. > > Rocky > > ----- Original Message ----- > From: "Stuart McLachlan" <stuart at lexacorp.com.pg> > To: "Access Developers discussion and problem solving" > <accessd at databaseadvisors.com> > Sent: Friday, September 05, 2003 5:40 PM > Subject: Re: [AccessD] A2K Reference the dot column property in a query > > > > On 5 Sep 2003 at 7:48, Rocky Smolin - Beach Access S wrote: > > > > > Must have missed that thread Arthur. What are static functions? > > > > > > > > > Functions which retain the value of their variables between calls. > > Something like: > > > > STATIC FUNCTION StartDate(OPTIONAL dteStartDate as Date) as Date > > Local dteStore as Date > > IF NOT ISNULLl(dteStartDate) Then > > dteStore = dteStartDate > > END IF > > StartDate = dteStore > > End FUNCTION > > > > Every time you call the function with a date parameter, it sets its > > value. Every time you call it without a parameter, it returns the > > last value set. > > > > You can now you user select a start date on a "pick form" somewhere. > > When they have picked it, set the value of Startdate() with > > something like dteTemp = StartDate(txtStartDate) > > > > Now you can use "=StartDate()" in reports, queries, form filters etc > > anywhere you like. It will return the selected value until the user > > goes back to the pick form and changes it. > > > > > > > > -- > > Lexacorp Ltd > > http://www.lexacorp.com.pg > > Information Technology Consultancy, Software Development,System Support. > > > > > > > > _______________________________________________ > > 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 > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/2003 > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/2003 > > _______________________________________________ > 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 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/2003