Using a Variable in a query or Report

  • Thread starter Thread starter Larry L
  • Start date Start date
L

Larry L

I have a global variable set to the file name of a linked table. I'd like
the value to appear in several reports. I can't figure out how to get it
into either the query that is the source of the report, or the report
itself. I know it can't be that hard, but I'm just missing the how.

Thanks much,
Larry L
 
I have a global variable set to the file name of a linked table. I'd like
the value to appear in several reports. I can't figure out how to get it
into either the query that is the source of the report, or the report
itself. I know it can't be that hard, but I'm just missing the how.

You need a silly little wrapper function in VBA:

Public Function GetTheVar() As <datatype>
GetTheVar = globalvariablename
End Function

Set the Control Source of a textbox to

=GetTheVar()

or use the function as a calculated field in a Query.
 
You need a silly little wrapper function in VBA:

Public Function GetTheVar() As <datatype>
GetTheVar = globalvariablename
End Function

Set the Control Source of a textbox to

=GetTheVar()

or use the function as a calculated field in a Query.

John,

Works perfectly, I knew it had to be easy! Thanks SO much!

Larry L
 
Back
Top