Variable in reports

  • Thread starter Thread starter Alex H
  • Start date Start date
A

Alex H

Hi I am creating a report which I want to insert some variables.
I assume I create an unbound text box and i then put the datasource as
=variablename, but that didn't work. Can someone tell me what the correct
syntax is please

thanks

A
 
Variables cannot be retrieved directly by text boxes.

You might use the Format event of the report section that contains the text
box, e.g.:

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
Me![SomeTextbox] = SomeVariable
End Sub

Alternatively, you could create a function to return the value of the
variable:
Public Function GetMyVariable() As Variant
GetMyVariable = SomeVariable
End Sub
Then you could set the Control Source of the text box to:
=GetMyVariable()
 
Thanks

Alex

Allen Browne said:
Variables cannot be retrieved directly by text boxes.

You might use the Format event of the report section that contains the text
box, e.g.:

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
Me![SomeTextbox] = SomeVariable
End Sub

Alternatively, you could create a function to return the value of the
variable:
Public Function GetMyVariable() As Variant
GetMyVariable = SomeVariable
End Sub
Then you could set the Control Source of the text box to:
=GetMyVariable()

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Alex H said:
Hi I am creating a report which I want to insert some variables.
I assume I create an unbound text box and i then put the datasource as
=variablename, but that didn't work. Can someone tell me what the correct
syntax is please
 
Back
Top