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!

OnFormat and OnPrint functioning unexpectedly

Status
Not open for further replies.

Robotron

Programmer
Mar 16, 2004
72
0
0
US
In the page footer of a report, I have the following controls:

txtPage: ="Page " & [Page] & " of " & [Pages]
lblDCApproval (a label)
linDCApproval (a line for a signature)
lblDate (a label)
lblDate (a line for a date of signature)

In the OnFormat and in the OnPrint events of the page footer, I have the following code:

Code:
If [Page] = [Pages] Then
    Me.lblDCApproval.Visible = True
    Me.linDCApproval.Visible = True
    Me.lblDate.Visible = True
    Me.linDate.Visible = True
End If

These controls are initially set to Visible = False.

My goal is to have the signature controls print only on the last page. Here is the issue: in the print preview, it functions as expected. When I print the report, the controls appear on every page. How do I get it to print only on the last page?

Phil Edwards
 
Phil,

Does the report work if you print it directly without previewing first??

You might want to try this:
Code:
If [Page] = [Pages] Then
    Me.lblDCApproval.Visible = True
    Me.linDCApproval.Visible = True
    Me.lblDate.Visible = True
    Me.linDate.Visible = True
Else
    Me.lblDCApproval.Visible = False
    Me.linDCApproval.Visible = False
    Me.lblDate.Visible = False
    Me.linDate.Visible = False
End If
It's usually good practice to code for both conditions...



Hoc nomen meum verum non est.
 
Is that in the OnFormat or in the OnPrint event of the page footer? Here is an interesting bit of info: the OnFormat event occurs 5 times for a 4 page report. Here is the page and pages values:

Page Pages
1 0
2 0
3 0
4 0
1 4

The OnPrint event occurs 1 time with the values 1 and 4. So with these 2 events of the page footer, page is never equal to pages.
 
I would put it in the On Format event only....

Hoc nomen meum verum non est.
 
Ok. That works. I am not sure why it works because it seems to me to be a bit redundant. Thanks for your help.

Phil Edwards
 
There are/were known problems with calculations, page numbering, etc. when first previewing then printing the report:

If you look at the above page you'll notice that the first resolution listed is to print the report without previewing it first...

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

Part and Inventory Search

Sponsor

Back
Top