Skip to main content

Hide a column or band when it is empty

Do not print a heading, a column or a band when there is nothing under it. A formatting rule that hides the control does this. The example uses the Invoice document type.

Before you begin​

  • Open the designer from a saved invoice, on a template you may change. See Design an advanced report.
  • A hidden control does not print, but it may leave the space it used. Check the spacing in the Preview tab after each step.
  • You hide with a rule whose visibility setting is off when its condition is true. See Styles and conditional appearance.

Steps​

Hide a note that is empty​

  1. Right-click the report and choose Edit Formatting Rule Sheet....
  2. Add a rule named HideEmpty. Enter the condition IsNullOrEmpty([Notes]), using the field Notes of the "Bill" table (the invoice header). In the formatting of the rule, set the visibility to off.
  3. Close the editor. Select the label that prints the invoice notes and the label that holds the word Notes. In Formatting Rules of the Properties panel, add HideEmpty.

Hide a column when no line uses it​

  1. Add a rule named NoDiscount with the condition Not [][Discount_ic != 0].Exists(). The expression is true when no item has a discount. Take Discount_ic from the "Bill Items" table: the "Discounts" table has a field of the same name. Take Discount_ic from the "Bill Items" table: the "Discounts" table has a field of the same name.
  2. Apply the rule to the header cell of the discount column and to its cell in the Detail band. The cells of the column hide together.

Hide a whole band​

  1. Select the band, such as a Group Footer, and add to it a rule whose condition is true when it should not print. For example [Total_ic] == 0, with Total_ic from the "Bill Items" table.

  2. Click the Preview tab. Check the spacing, then click Save.

Result​

An invoice with no notes prints without the notes line and its heading. An invoice with no discount prints without the discount column. An invoice that has them prints as before. The data is not changed: only the printed page is.

If something goes wrong​

SituationWhy it happensWhat to do
A gap is left where the column was.The remaining cells do not take the free width.Resize the remaining cells, or design a second template without the column.
The control hides in every invoice.The condition is always true.Test the condition with an invoice that has a value.
A text with spaces is not hidden.The field holds spaces, so it is not empty.Test Trim([Notes]) instead, or Len([Notes]) == 0.

This page applies to alameen ERP 10, version 10.1.79.764.