Detail_Format works in Print Preview but Not When Printing

G

gschuck18

I am trying to use the technique of having a page break widget in my detailsection to control when a new page should be generated. In my Detail_Format section of the report, my code looks like:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If (Me.Page = 1 And firstTime) Then
Me![pageBreak].Visible = False
Else
Me![pageBreak].Visible = ((Len(Nz(data1, "")) > 0) And (Not (firstTime)))
End If
firstTime = False
End Sub

where data1 represents the key field that I am using to generate a new page.. The boolean "firstTime" is set TRUE in the Report_Open procedure. The widget "pageBreak" is located at the very top of the Detail section.

When this code executes in print preview mode, the resulting report is perfect. However, when I then ctrl-P to print that report, the pageBreak widget is printed on the first page which results in a blank detail section. The printed version is then one page longer than the preview version -- with the addition of this blank detail page.

I have put breakpoints in the Detail_Format section. They are not hit whenactually printing a hard copy, only when generating the print preview.

What am I missing? How do I control the page break when printing a hard copy like I can when doing a print preview?
 

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