Public Variables
Your use of the value in a table is actually the preferred method.
Global variables are somewhat risky. In the example you give probably
not much risk at all. The risk is that a global variable can be
modified anywhere in your code. From the depths of your code you
don't always know how program execution got to the current line. Many
a frustrating hour and day has been frittered away by people chasing
problems caused by global variables. Somewhere else in your code the
variable is assumed to have a value that reflects a certain state of
affairs. Other code was written with other assumptions.
The consequences are right up there with failing to require definition
of variables before their use. In those cases, a typing error will
quietly create a new variable for you.
HTH
--
-Larry-
--
"Pierre de Beer" wrote in message
...
Hi
I store the company name that is displayed on all my forms in a
table. I use
DLookup("[Company Name]", " Company Details") to retrieve the
company name
from this table. Is it not better to retrieve the company name at
startup
and store it to a global variable?
If the variable option is the best, how do I declare a global
variable in
Access? I declare the variable in a module but can not get a value
assigned
to it.
As you can see I am new at this.
Kind Regards
Pierre
|