Skip to content

Eliminating Blank Space on Reports

How to shrink up the blank spaces on reports.

Q:  Randy writes:  “I was wondering if there was any way I could shrink up the blank spaces on a report. The CanShrink Property just kinda shifts the blank spaces from the bottom of the detail section to the top in each group of records. I have an If, Else that hides text boxes that make up a row in the report when a field in the under lying query is set to no but then I have a lot of blank space on the report that makes it twice as long. Is there any way to suck up all that blank space. Any tips would be very appreciated.”

A:  CanShrink is rather cranky – to get optimum results, you have to have no vertical space between controls, and only one control per row.  If that is the case, and you set CanShrink to Yes for both the controls (one per row) and the section, it should work OK.  However, those restrictions are pretty limiting.  Sometimes you can get around the limitations of CanShrink by putting the controls you want to disappear (with no leftover space) in a group header or footer section, and write code on the section’s Format event to make the section invisible if a certain condition is met.  This is practical if the controls in question can be placed at the top or bottom of the group of controls (so when placed in the group header or footer, they look OK).  Here is a sample procedure to make a group footer section invisible if a field has no amount in it:

Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
 
   If Nz(Me![TotalPrice]) = 0 Then
      Me.Section(acGroupLevel2Footer).Visible = Falsee
   Else
      Me.Section(acGroupLevel2Footer).Visible = True
   End If
      
End Sub
 

Look up the Section topic (for Reports) in Help to see the named constants for referencing report sections.

About this author

Office 2024 - all you need to know. Facts & prices for the new Microsoft Office. Do you need it?

Microsoft Office upcoming support end date checklist.