Conditionally printing pages

D

DZ

Hello

I posted this problem earlier and I am still struggling with it.
None of the posts have helped me solve this so far so I am posting again.
Thanks for any help with this.

This one seems to be a REAL CHALLENGE.

My Report has Detail, pageheader and pagefooter Sections.

I want the report to have maximum of 3 pages for most records, and 2 pages
for some records depending on the conditions described below in the next
paragraph. I placed 2 page break controls in detail section.


The Report's RecordSource contains a field called AccountName.
A textbox with AccountName as the ControlSource is in the Detail section.
AccountName contains some null values. For the records that contain a null
value in the AccountName field, I want only page 1 and page 2 formatted and
printed, but not page 3. So some records will have 2 pages and some will have
three, depending on whether AccountName is null.

I tried the following that did not work.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

'If AccountName is null and its the third page, skip that page.
If IsNull(Me.AccountName) And [Page] Mod 3 = 0 Then
MoveLayout = False
NextRecord = True
PrintSection = False
Else
MoveLayout = True
NextRecord = True
PrintSection = True
End If

End Sub
'The problem I can't solve is how the identify the page that I don't want
printed. The problem is that the page numbers become confusing when a page
is skipped.

I also tried the following that did not work

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If IsNull(Me.F) Then
Me.PageBreak2.Visible = False

Else

Me.PageBreak2.Visible = True
End If

End Sub

Thanks again for any help
 

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