Suppressing sub reports

S

Steve

I have several sub reports that on my main report. When
there isnt any data for a sub report, I need the sub
report to be skipped. Currently a blank page is created
with a page number. I was sent the code below, but I am
not sure what should be coded in the control
names/lblAlternate1Label I have 4 sub reports:
PGMRpt,CopybookRpt,ProcRpt,JCLRpt. Help!
-----------------------------------------------------------
You can use code in the On Format event of the section
containing the subreport like
Dim booHasData as Boolean
booHasData = Me.srptMySubreport.Report.HasData
Me.lblAlternate1Label.Visible = Not booHasData
Me.lblAlternate2Label.Visible = Not booHasData
Of course you will need to use your subreport and control
names.
 
D

Duane Hookom

If the subreports don't have data, they won't display. You haven't stated
what is causing the page creation. Do you have a Page Break control that
needs to be hidden? Are you getting a large blank space in the report?

Your previous question IIRC was to show headers even though the subreport
might not have data.
 
G

Guest

I do have page breaks between sub reports. I need only
reports that have data to print. what's happening now is
sub report 2 has no data and what prints out is page1 =
Sub report 1, page 2 = blank, page3= sub report3, page4=
sub report 4. I need to have only the sub reports that
have data to actually print(no blank pages). Hope this
explains it a little more clearly, sorry for the confusion.
 
D

Duane Hookom

Your page break controls should have descriptive names so you can reference
them in code.
Dim booHasData as Boolean
booHasData =
Me.pagebreak1.Visible = Me.srptMySubreport1.Report.HasData
Me.pagebreak2.Visible = Me.srptMySubreport2.Report.HasData
Me.pagebreak3.Visible = Me.srptMySubreport3.Report.HasData
'etc of course substituting your control names for the "generic" ones
above
 
S

steve

Still having problems... with stmt booHasData =
I get compile error: expected expression
I have coded:
Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
Dim booHasData As Boolean
booHasData =
Me.PageBreak1.Visible = Me.CopybookRpt.Report.HasData
Me.PageBreak2.Visible = Me.PgmRpt.Report.HasData
Me.PageBreak3.Visible = Me.CarddataRpt.Report.HasData
Me.PageBreak4.Visible = Me.JCLRpt.Report.HasData
End Sub
 
D

Duane Hookom

Sorry shouldn't be any booHasData... just:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me.PageBreak1.Visible = Me.CopybookRpt.Report.HasData
Me.PageBreak2.Visible = Me.PgmRpt.Report.HasData
Me.PageBreak3.Visible = Me.CarddataRpt.Report.HasData
Me.PageBreak4.Visible = Me.JCLRpt.Report.HasData
End Sub
This assumes you have renamed your pagebreak controls.
 
Top