Using Global Variables in Reports

D

dryan

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.
 
N

Nikos Yannacopoulos

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.
 
M

Marshall Barton

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
 
R

Rick Brandt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top