Report with subreports printing blank pages when no data

pityocamptes

Registered User.
Local time
Yesterday, 17:00
Joined
Dec 8, 2010
Messages
27
I realize that subreports will not print when data is not present. However, I have a main report with about 6 subreports below it. I'm getting several BLANK pages when the subreports have no data. How do I suppress this so that I do not get half a dozen BLANK pages??? Thanks!
 
I tried using this code:

Private Sub cmdprint_Click()
Dim strCriteria As String
strCriteria = "[UserID] = " & Me![UserID]
If gfReportHasNoData1 = True Then
MsgBox "There are no records to report", vbExclamation, "No Records"
Cancel = True
Else
MsgBox gfReportHasNoData1, vbExclamation, "no records"
DoCmd.OpenReport "rptSingleRecord1", acViewNormal, , strCriteria
DoEvents
End If
End Sub


but for some reason gfReportHasNoData1 is returning FALSE and the report is printing, but I am getting BLAMK pages, so I assume that it should be TRUE?? Why is the var returning FALSE, yet I get blank pages on the print????? Thanks!
 
We don't know what code you've got under gfReportHasNoData1.

To check if your subreport has data use one of these methods (in code):

1. If Me![SubreportName].Report.RecordsetClone.RecordCount = 0 Then
2. If Me![SubreportName].Report.HasData = False Then

Where SubreportName is the name of the subreport control not the name of the subreport's report.

Perform this check in the FORMAT event of the section where the subreports are.

To resolve the issue, have you will need to perform the check as explained above and if all subreports have no data, set the subreport's control's TOP property to zero, reduce and reduce their height to something like 100. You will also need to ensure that the section's Can Shrink property is set to YES.
 

Users who are viewing this thread

Back
Top Bottom