View Single Post
  #2  
Old February 23rd, 2006, 05:44 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Public Variables

you would declare the variable in a standard module (not a form or report
module), and put it at the top of the module, directly after the Option
Compare and Option Explicit statements.

you would have to set the value of the variable in code. you can do this in
any event procedure. suggest you use the Open or Load event of the first
form that opens when the database is opened. or you can write a public
function in a standard module to set the value of the variable, and run the
function from an AutoExec macro, which will automatically run when the
database opens.

on each form's Load event, you would add code to set the value of the
textbox control that displays the company name, as

Me!TextboxName = GlobalVariableName

as for which one is better: unless you have a whole lot of records in your
CompanyDetails table and/or are experiencing a noticeable lag in getting the
company name control populated when the form opens, i probably wouldn't
bother with all of the above, and would just use the DLookUp().

hth


"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