Displaying Variables in Reports

A

apollo8359

The following solution was given by Allen Browne for a question about how to
display public variables in a report, however, I don't know where to put this
code. In my database all the reporting code is in a "Main Module", in a
procedure called Reports, there is no code behind the form, which is
completely unbound. The variable I want to display [ReportDate] is already
public as a string, but the report won't recognize it as he states below. The
string [ReportDate] is a concatenation of the startdate and stopdate so the
report will display "1/1/2006 through 3/31/2006", if that helps. Anyway,
could anyone advise me on where to put this code, thanks

You cannot read the data from variables directly into a text box. The
workaround is to create a function to return the value of the variable,
e.g.:
Public MyVar As Variant
Public Function GetMyVar() As Variant
GetMyVar = MyVar
End Function
You can then set the Control Source of your text box to:
=GetMyVar()
 
M

Marshall Barton

apollo8359 said:
The following solution was given by Allen Browne for a question about how to
display public variables in a report, however, I don't know where to put this
code. In my database all the reporting code is in a "Main Module", in a
procedure called Reports, there is no code behind the form, which is
completely unbound. The variable I want to display [ReportDate] is already
public as a string, but the report won't recognize it as he states below. The
string [ReportDate] is a concatenation of the startdate and stopdate so the
report will display "1/1/2006 through 3/31/2006", if that helps. Anyway,
could anyone advise me on where to put this code, thanks

You cannot read the data from variables directly into a text box. The
workaround is to create a function to return the value of the variable,
e.g.:
Public MyVar As Variant
Public Function GetMyVar() As Variant
GetMyVar = MyVar
End Function
You can then set the Control Source of your text box to:
=GetMyVar()

Create a new standard module (not a class module) and put
the code in there.
 

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