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
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.
: