dave said:
Once a global constant is defined, how can I use it in a Form or Report? I
want to create a company name constant and then use it globally on each
form/report, etc.
Global variables are VBA variables that are declared Public
in a standard module's declaration section (before any
procedures).
However, they are VBA variables and are not in the name
space of queries or form controls, which use the Expression
Service, not VBA. The only VBA declared thingies that are
recognized by the expression service are Public Functions in
standard modules.
What all that means is that a query or a text box expression
has to use a Function to retrieve the value of a global
variable. For example: If you have a standard module with
Public gstrName As String
Public Function GetName() As String
GetName = gstrName
End Function
Then VBA code in any module, even a class module behind a
form/report, can just use gstrName as if were declared
locally. BUT a query or text box expressiom must use
GetName() to retreive the value in the variable.