Using Global Variables in Reports

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

Guest

How can I reference a global variable in a report? I have no problem setting the global variable into a FORM TextBox but I can't get a REPORT to recognize the variable.
 
Can't do it directly. Use a function to return the variable's value, and
reference the function in the report.

HTH,
Nikos


dryan said:
How can I reference a global variable in a report? I have no problem
setting the global variable into a FORM TextBox but I can't get a REPORT to
recognize the variable.
 
dryan said:
How can I reference a global variable in a report? I have no problem setting the global variable into a FORM TextBox but I can't get a REPORT to recognize the variable.


The form text box approach is a pretty standard way to do
this kind of thing. Just make sure the form stays open (can
be invisible) while the report is running. The report can
refer to the text boxes on the report by using syntax like:
Forms!nameofform.nameoftextbox
 
dryan said:
Thanks for input. I tried using a function but I don't know where to put it
so that the TABLE recognizes the FUNCTION and the FUNCTION recognizes the GLOBAL
Variable.

A report should be able to use a global variable (in code). This is the same as
a form. If you want to use it in a query or a ControlSource expression then you
need a wrapper function. That is a function whose only purpose is to return the
global variable value.

Public Function GetVariableName() as VariableType
GetVariableName = VariableName
End Function

Once created you can use...

=GetVariableName()

....in a ControlSource expression.
 
Back
Top