Suppress Group Footer When Only One Detail

When you are calculating totals in the group footer band, it is often useful to suppress the group footer band when only one detail band exists for the group.  This simplifies the format of the report, because it is unnecessary to repeat the same number twice (once in the detail band and once in the group footer).  By assigning two very simple event handlers, we can easily suppress the printing of a group footer band for this case. Our strategy will be to set the visibility of the group footer to False, when the group first breaks, and then set the visibility to True as soon as more than one detail band prints for the group. To accomplish this we will assign two event handlers: one to the BeforeGenerate event of the Group Header band, and one to the AfterGenerate event of the Detail band.

The first event handler should be assigned to the Group Header band. It is important to keep in mind that the Group Header band prints for two very different reasons:

  1. The group is breaking
  2. The detail for the current group does not fit on a single page and the group is continuing onto a subsequent page.

We need to set the visibility of the group footer to False when the group breaks, so we want to make sure the group header is printing for condition one only, not condition two.  Thus our event handler will read:

FirstPageNo is a property of a group which indicates the FirstPageNo on which the current group break occured.  Basically we are making sure that the group header is printing because of a group break and not a on subsequent page of the same group break.

The second event handler will set the visibility of the Group Footer to True, if more than one detail band prints for the group:

The Count property of the Detail band tells us how many times the detail band has printed since the last group break.