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
- Right-click the report and choose Edit Formatting Rule Sheet....
- Add a rule named
HideEmpty. Enter the conditionIsNullOrEmpty([Notes]), using the fieldNotesof the "Bill" table (the invoice header). In the formatting of the rule, set the visibility to off. - 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, addHideEmpty.
Hide a column when no line uses it
- Add a rule named
NoDiscountwith the conditionNot [][Discount_ic != 0].Exists(). The expression is true when no item has a discount. TakeDiscount_icfrom the "Bill Items" table: the "Discounts" table has a field of the same name. TakeDiscount_icfrom the "Bill Items" table: the "Discounts" table has a field of the same name. - 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
-
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, withTotal_icfrom the "Bill Items" table. -
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
| Situation | Why it happens | What 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. |
Related
This page applies to alameen ERP 10, version 10.1.79.764.