If you declare constants, or any variable in a standard module as
public..then it is available in all code, forms reports.
However, just remember that you can shove, or reference a constant, or
variable value directly in a text box.
If you need to use a variable directly in sql statements, or in a text box,
then you need to wrap the variable in a public function, and then that
public function can be used;
So, I can shove a global variable into a text box with some code like:
forms!Customers!City = gblDefaultCity.
But I can NOT just put glDefaultCity in the text box expression. So, text
box, and for that matter all controls don't allow you to put a variable name
directly in them as the data source. You have to use code to load up the
text box. Those global vars are available in code anywhere in the
application.
However, you can put in a global function name, so, you can go:
=MyGlobalFunctionName()
The global function is placed in a standard module...like
Public Function MyGlobalFunctionName as string
MyGlobalFunctionName = gblDefaultCity
end function
Note that you can place form expressions anywhere...so often in place of a
few global vars...we create a form, set the values..and then make the form
invisible. This is often preference since any un-handled code executing
error will re-set all of your global vars. (if you make a mde then this is
not the case...and again one great reason why most developers always
distribute a mde in place of a mdb).