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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Bottom Align The Report Footer? 1

Status
Not open for further replies.

dwilson1976

Programmer
Apr 26, 2001
16
0
0
US
A2k reports.

What I am trying to do is get a section of my report to only print on the bottom of the last page. So, I either need to bottom align the report footer, or I need to only print the page footer on the last page. Either one will do.

Anyone know how to do either?

THANKS...
 
This is a little workaround that I figured out. It requires a bit of testing to see how many detail records print on each page. This is important because we need to calculate what the last page number is. So, create your report and with all of your headers and group headers and run a test and count the number of detail records that will display. This value will be used to determine when the last page is being printed.

Now you may or may not being using the PageFooter. I want to set the controls for your pagefooter to visible. Now create your controls for the report ending footer and set their visible properties to No. The PageFooter will print throughout the report the page footer info and then on the last page we will set those controls to visible = NO and change the report ending controls visible = Yes.

Don't change the size of the page Footer as this will change the number of records on each page.

Copy and Paste this VBA code into the code window:

Code:
[red]Option Compare Database[/red]   'Do not Duplicate
Dim vPageCount As Long

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Page = vPageCount Then
    Me.[[b][red]report_ending_controls[/red][/b]].Visible = True
    Me.[[b][red]pageheader_controls[/red][/b]].Visible = False
End If
End Sub

Private Sub Report_Open(Cancel As Integer)
vPageCount = IIf(DCount("*", " [i][red]yourtablename[/red][/i] ") Mod [b][blue]5[/blue][/b] = 0, Int(DCount("*", "[i][red]yourtablename[/red][/i]") / [b][blue]5[/blue][/b]), Int((DCount("*", "[i][red]yourtablename[/red][/i]") / [b][blue]5[/blue][/b])) + 1)
End Sub

In the above code change the bolded red code to the names of the controls as identified. There may be multiple lines for True and multiple for False depending upon the number of controls you have in mind. But, the idea is to have the page footer controls visible all the time except for the last page and have the report ending controls invisible all the time except for the last page.

The blue bolded number is the number of detail records that you have determined will print on each page after you create the page footer. Change this to this number.

Post back if you have any questions.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
If you only want to print the page footer on the last page, try something like this:

In your page footer, if you don't have one already, add a text box whose control source holds the Page and Pages properties. Something like:

Code:
="Page " & Page & " of " & Pages
Make it invisible if you don't want it to appear.
In the On Format event of your page footer place code like this to cancel the printing of the page footer unless it is the last page of the report:

Code:
If Me.Page <> Me.Pages Then
   Cancel = True
End If

Hoc nomen meum verum non est.
 
CosmoKramer: Thanks for that. I struggled through the long trying to identify the last page. Yes, this is much better. Star for you from me. Sometimes we struggle to makes things harder they appear or are, Right???

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Bob,

That's right, it's not any fun sometimes unless it takes a little effort [wink]

"Can't see the forest for the trees" syndrome. That happens to me a lot....

Thanks for the star......

Hoc nomen meum verum non est.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top