Referencing global constants from reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I must be missing something really basic. I want to set certain global
constants for use across the board in forms and reports. I defined them in as
public constants in a module. The debugging window shows that things are set
right, but I can't seem to get them referenced in the reports themselves.
Hints? Thanks in advance.
 
Do you have a public function in a standard module that returns the value of
the global constant? Otherwise, how were you attempting to reference them?
 
Duane, thanks for your fast response to what is most likely a fundamental
misunderstanding....

Here's what I did in a module called modGlobals

Option Compare Database
Option Explicit

Public Const gClientInits As String = "ABCD"
Public Const gClientName As String = "Client"
Public Const gProprietary As String = "Proprietary and Confidential to " &
gClientInits


I had thought I could refer to these in various reports by setting text
boxes =[gClientInits], etc.
 
Bruce said:
Duane, thanks for your fast response to what is most likely a
fundamental misunderstanding....

Here's what I did in a module called modGlobals

Option Compare Database
Option Explicit

Public Const gClientInits As String = "ABCD"
Public Const gClientName As String = "Client"
Public Const gProprietary As String = "Proprietary and Confidential
to " & gClientInits


I had thought I could refer to these in various reports by setting
text boxes =[gClientInits], etc.

Variables can only be referenced directly from within VBA code. In Queries
and expressions on forms and reports you need to build a function that
returns the value of the variable and then use the function instead.
 
Thanks Rick,
A function might be:

Public Function GetgClientInits() as String
GetgClientInits=gClientInits
End Function

You can then set a control source property to
=GetgClientInits()

--
Duane Hookom
MS Access MVP
--

Rick Brandt said:
Bruce said:
Duane, thanks for your fast response to what is most likely a
fundamental misunderstanding....

Here's what I did in a module called modGlobals

Option Compare Database
Option Explicit

Public Const gClientInits As String = "ABCD"
Public Const gClientName As String = "Client"
Public Const gProprietary As String = "Proprietary and Confidential
to " & gClientInits


I had thought I could refer to these in various reports by setting
text boxes =[gClientInits], etc.

Variables can only be referenced directly from within VBA code. In
Queries
and expressions on forms and reports you need to build a function that
returns the value of the variable and then use the function instead.
 
Thanks, Duane and Rick - this solved my (current!) problem.
--
Bruce


Duane Hookom said:
Thanks Rick,
A function might be:

Public Function GetgClientInits() as String
GetgClientInits=gClientInits
End Function

You can then set a control source property to
=GetgClientInits()

--
Duane Hookom
MS Access MVP
--

Rick Brandt said:
Bruce said:
Duane, thanks for your fast response to what is most likely a
fundamental misunderstanding....

Here's what I did in a module called modGlobals

Option Compare Database
Option Explicit

Public Const gClientInits As String = "ABCD"
Public Const gClientName As String = "Client"
Public Const gProprietary As String = "Proprietary and Confidential
to " & gClientInits


I had thought I could refer to these in various reports by setting
text boxes =[gClientInits], etc.

Variables can only be referenced directly from within VBA code. In
Queries
and expressions on forms and reports you need to build a function that
returns the value of the variable and then use the function instead.
 
Back
Top