Re: What is common practice?
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Thu, 20 Sep 2007 01:06:43 +0800
It is a question of style, Jim, but I don't like globals because:
a) They lose their value when you reset your code, making them harder to debug.
b) You have to restart the application before any change gets to them.
c) There's always the problem of a local variable being clobbered by a global with the same name, and vice versa.
So my compromise is to read the value in the Load event of any form that depends on it.
BTW, I also prefer to store these configuration settings/values as records instead of fields in this table. This has the advantage of being more flexible (you can easily add more settings, just with another record), but the disadvantage that they are untyped (typically a Text (255) field, so you must validate if it is to store a date or number.)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Jim Franklin" <pleasedonotusethis@xxxxxxxxxxx> wrote in message
news:WzcIi.9055$gZ.7764@xxxxxxxxxxxxxxxxxxxxxxx
Just something I have often wondered, as it crops up with almost every application...
If you have a 1-record table which contains various settings for an application, and those settings are used frequently in different functions of the app, say via a function which opens the tbl_Settings recordset and returns the appropriate field, is it more common (and more efficient) to run the function every time a setting is needed, or to use a global variable, and use the function only once at startup to assign the variable value.
I know this isn't a 'Help! How do I...' question, but if anyone can answer this I would be very grateful,
Cheers,
Jim
.
- References:
- What is common practice?
- From: Jim Franklin
- What is common practice?
- Prev by Date: What is common practice?
- Next by Date: Re: Unbound Textbox formatted as a time format
- Previous by thread: What is common practice?
- Next by thread: Re: What is common practice?
- Index(es):
Relevant Pages
|