Question about reports, subreports, and page breaks

D

David

Folks,

I have four subreports in a report in the detail section. I suppose I
could move them to the footer of the report. Anyway, if any of them
have data, I want the main report to force a page break. I am trying
to use the "hasdata" property for the subreports, but I am getting the
generic error indicating property not available for object.

How does one tell the main report (using VBA) not to throw in a page
break unless the subreport has data? There has to be an easy set of
code for this. Thanks.

David
 
A

Albert D. Kallal

David said:
Folks,

I have four subreports in a report in the detail section. I suppose I
could move them to the footer of the report. Anyway, if any of them
have data, I want the main report to force a page break. I am trying
to use the "hasdata" property for the subreports, but I am getting the
generic error indicating property not available for object.

The code in the detail section (on format event) would look like:

If Me.rptNameOfSubReprot.Report.HasData = True Then

Me.Detail.ForceNewPage = 1

End If

It is not clear if these sub-reports are child reports of EACH detail RECORD
for the main report?

give the above a try anyway. (check out the help for forceNewPage):

(I just hit the help, and the following was displayed:

Setting Visual Basic Description

None 0 (Default) The current section (the section for which you're
setting the property) is printed on the current page.


Before Section 1 The current section is printed at the top of
a new
page.

After Section 2 The section immediately following the
current section
is printed at the top of a new page.

Before & After 3 The current section is printed at the top of a
new
page, and the next section is printed at the top of a new page.


So, try a value of 1, or 3...
 
D

David

This code actually solved my problem (with a little jiggling here and
there):

If FormatCount = 1 Then
If Me!YourSubRptName.Report.HasData = True then
Me!NameOfFirstPageBreakControl.Visible = True
Else
Me!NameOfFirstPageBreakControl.Visible = False
End if
'........Repeat for each sub report.


End if

Thanks for the input!
 

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