Variable in reports

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
 
A

Allen Browne

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()
 
A

Alex H

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
 

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