Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding variables to a control in a footer 1

Status
Not open for further replies.

RonMcIntire

Technical User
Oct 12, 2002
166
0
0
US
All:
Does anyone know if I can add a variable to a control in a report footer?
Example: =" - " & [Page]+ StartPageNO & " - " where StartPageNO is the variable.

If there is, how do I do it?
 
Where is the variable coming from? A textbox on the form? Manually entered when prompted? Global Variable?
Here are some example ideas.

In the report footer using a form as data source:
[tt]="Page " & [Page]+[Forms]![frmName].[FieldName_or_TextBox][/tt]

In the report footer using a function as data source:
[tt]="Page " & [Page]+mypageno()[/tt]

Add this to a Standard Module
Code:
Public Function mypageno()
'Add a custom starting page number when the report loads
'20220223
    mypageno = InputBox("Enter Starting Page Number:", "PageNo")
End Function

In the report footer using a global variable as data source:
[tt]="Page " & [Page]+mygblPgNo()[/tt]

Add this to a Standard Module
At the top before any subs or functions add
[tt]Dim gblPageNo as Long[/tt]

Then add this function
Code:
Public Function mygblPgNo()
'Add a custom starting page number based on a global variable
'20220223
    mygblPgNo = gblPageNo
End Function
 
sxschech:
The variable is coming from the form that populates the report.

To wit: I'm trying to create a Title Page for a directory. The form contains the following fields:
Title of the page in the directory​
The Report name​
StartPageNO​
EndPageNO​
Calculated number of pages​

The Title Page report uses the data to make the Table of Contents. But, I need to make sure the page numbers in the TOC agree with each page in the directory. Plus, adding a number to each page control is pain and is open to mistakes.

I thought I could add the variable, StartPageNO, to [Page] control, but that doesn't work.
One of your suggestions may solve my problem.

These are great starting points. I'll give them a try, unless you have others.
Tnanks,
Ron
 
Thanks Ron, glad the suggestions worked for your situation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top