dbTalk Databases Forums  

Forcing page breaks where you need them in subreports

comp.databases.ms-access comp.databases.ms-access


Discuss Forcing page breaks where you need them in subreports in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
pemigh
 
Posts: n/a

Default Forcing page breaks where you need them in subreports - 04-28-2010 , 03:59 PM






Since explicit page break controls are ignored in subreports, I had a
devil of a time getting things to display properly. My solution is
below.

The scenario: My main report sometimes has “spec sheets” that need to
be printed along with the main information. These need to be included
in overall pagination, and each needs to start on a new page. The
spec sheets come in different flavors, and there may be 0, 1, or
multiple spec sheets for each flavor.

The spec sheets are actually sub-subreports since I created one
subreport to hold them all. Main report was already very complicated,
so this was mainly an attempt to hold on to some level of sanity while
messing around with and troubleshooting page breaks. And here’s what
makes it all work:

-- The first-level subreport has dummy group headers where the “field/
expression” is simply 1, and each spec sheet is in its own dummy group
header.

-- Each of these group headers has "Force new page" set to "after
section."

-- On each spec sheet, the first group header has "Force new page" set
to "before section."

-- A little bit of code is required to prevent extra blank pages.
Each dummy group header on the containing subreport needs OnFormat
code to set visibility based on check for null spec sheet report. This
code exploits the fact that Error 2427 will fire if there is no spec
sheet matching the data in this report:

Private Sub Hdr1_Format(Cancel As Integer, FormatCount As Integer)
On Error Resume Next
varTestForNull = Me![rptSpecSheetInHdr1].Report![txtWhatever]
If Err = 2427 Then
Hdr1.Visible = False
Else
Hdr1.Visible = True
End If
Err = 0
End Sub

Hope this helps somebody else, but even if not I'll probably need it
myself some day. And now I'll be able to google it instead of trying
to remember which report in which project holds the solution. (Too
many projects, too many birthdays to be able to hold it all in this
old brain.)

Cheers!

pemigh

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.