> My aversion to global variables is exceeded only by my aversion to the GoTo.
> Here is a function that replaces the need (there really is never a need) for
[quoted text clipped - 22 lines]
>>in the 'open form' method). How would I go about storing/accessing this
>>string for later use when I open the form?
The wider the scope of a variable, the more apt the value of the varialbe is
to be suspect. If you are the only developer in an application, then it
doesn't matter as much.
In reality, there is not that much difference between the two. I quess I
picked up the preference in other languages where globals are a little harder
to manage. It is mostly style, as in avoiding the GoTo.
Global variables can be over used, in other words, used when they are not
necessary. So, if you put a taboo on them, you may not eliminate them, but
hopefully make people think before using them.
In this particular case, we don't really know where his code exists. Could
it be in the same module that he does the updates that he calls the OpenForm?
If so, a module level variable would be more appropriate.
> Could you elaborate as to the differences between the two and your
> aversion to globals?
[quoted text clipped - 25 lines]
> >>in the 'open form' method). How would I go about storing/accessing this
> >>string for later use when I open the form?
David C. Holley - 19 Sep 2005 16:56 GMT
So then I wasn't wacked out in using Global's to replace multiple
DLookup's of the same information across multiple SUBs? In my DB, the
table tblTransports is more or less the core of the database. As such, I
had multiple SUBs (createOutlookAppointment, createLedgerEntry,
updateLedgerEntry, etc.) that used DLookups to grab the relevant
information from the table - date, time, origination, destination, etc,
etc. To streamline things, I created a SUB - loadTransport() that takes
the record ID of the transport and sets related global variables for use
in the various SUBS. The globals are set by using DAO to grab the
record. The thinking is that it would be easier to use Globals as
opposed to 10+ DLookups on the same table.
David H
> The wider the scope of a variable, the more apt the value of the varialbe is
> to be suspect. If you are the only developer in an application, then it
[quoted text clipped - 38 lines]
>>>>in the 'open form' method). How would I go about storing/accessing this
>>>>string for later use when I open the form?
Klatuu - 20 Sep 2005 13:55 GMT
I don't think that is wacked out at all. There is valid justification for
breaking almost any rule if the alternative makes sense by improving
efficiency.
> So then I wasn't wacked out in using Global's to replace multiple
> DLookup's of the same information across multiple SUBs? In my DB, the
[quoted text clipped - 52 lines]
> >>>>in the 'open form' method). How would I go about storing/accessing this
> >>>>string for later use when I open the form?