How do I print the content of a VBA varaible to a report?

G

Guest

Hi, I have created a simple report with only one textbox (unbound). In my vba module, there is a variable named "Var1". Can anyone tell me how to print Var1 to the textbox on the report? Thanks.
 
D

Dirk Goldgar

Jacky Chan said:
Hi, I have created a simple report with only one textbox (unbound).
In my vba module, there is a variable named "Var1". Can anyone tell
me how to print Var1 to the textbox on the report? Thanks.

Your text box can't read the variable directly. You can either have a
function in the module that simply returns the value of the variable,
and then set your text box's controlsource to an expression that calls
the function; e.g.,

=fncGetVar1()

or if the variable is Public, you can have code in a report event to set
the value of the textbox to the variable's value.
 
D

Doug Chinnock

One way is to have a text box in a form.

Say the form is "frmData" and the Name of the TextBox is "boxVar1";
then its contents can be referenced from a report launched from the form.
They would be referenced as "=[Forms]![frmData].[Form]![boxVar1]".

Jacky said:
Hi, I have created a simple report with only one textbox (unbound).

In my vba module, there is a variable named "Var1".
Can anyone tell me how to print Var1 to the textbox on the report? Thanks.
 

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