Chapter 11: Customizing Reports and Labels

 

Report and Label project items contain many sub-items that are used in the construction of a report or label. There are visual items referred to as sections and components used in the layout of the report/label and there are non-visual items such as parameters, computed fields, the record source, and the report/label user-defined Java event methods, methods, and variables (defined in the source code or the Java classes accessible on the class path for this project).

 

Every report and label is backed by a record source. This is a SQL Query that is local to the report or label. In the report and label designer window, the tabs Record Source, Datasheet, and SQL refer to the sub-editors used to modify the SQL Query associated with this report or label. The Record Source view provides a visual SQL Query editor. The Datasheet view provides a read-only view of the results returned by the SQL query associated with the report or label in a table format. Grouping and sorting options are added to this query through the Grouping and Sorting dialog box. This allows you to design a record source that is sorted in a specific order and also allows you to determine whether a group header and footer section should be associated with the specified sort group in the report design. A label and query can only be sorted through the Grouping and Sorting dialog box, only a report can have group header and footer sections.

 

A parameter is a variable that is passed to the report or label at print time. Normally, the parameter is prompted for at print time to allow a user to control the behavior of the report or label, but it may be configured to be hidden and then later set in the On Open event method of the report or label.

 

A computed field is a variable used to compute an aggregate (SUM, AVG, MIN, MAX, FIRST, LAST, STDEV, VAR, etc.) value, a calculation, or act as a counter (returning a sequence of values) over a report (all records of the record source), sort group (all records contained in each group defined by the user in Grouping and Sorting), detail (at each record of the record source), or page.

 

A label is restricted to contain only one detail section and that detail section is further restricted to cover the printable area of the paper stock and it cannot grow or shrink. The printable area is one label for a labeled stock or the printable area of the paper stock. See Chapter 16: Working with Paper Stocks for more details. A report can always be used to create a label as it is the general form of all output capable of being produced by this product. Creating a label is useful when you only need to print one record per label. For example, print address labels from a list of addresses.

 

A report (unlike a label) can contain many types of sections: Report Header, Report Footer, Group Header, Group Footer, Detail, Page Header, and Page Footer. The Report Header, Report Footer, Page Header, Page Footer, and Detail sections may be optionally hidden.  The Group Header and Group Footer are sections associated with user-defined sort groups that are created through the Grouping and Sorting dialog box. In this dialog box, you can show or hide the Group Header and/or Group Footer section for each individual sort group you have defined.

 

A report section or label may contain a collection of design components: Text Field, Sub Report, Section Break, etc. A Sub Report cannot be placed in a label. A Section Break cannot be placed in a label or report Page Header or Page Footer section. Each design component is described in further details later in this chapter. Note, however, that a Sub Report allows a report to be nested inside another report and a Section Break allows you to control where a section needs to be broken when it crosses over more than one physical page and/or row/column area. A section can be any length (height) with the exception of the report Page Header and Page Footer, which must be less than the page height when added together. Also, sections can shrink or grow based on their content, and this behavior is controlled through the Can Shrink and Can Grow section properties.

 

By defining these sub-items in a report and/or label you specify both the layout and values that will be printed on the printed report or label.

 

In addition, a report or label cab contain Print To sub-items that are used to control the kind of output created by running this report or label. This provides the ability to simply run the report and/or label and have the results printed in multiple locations and formats at the same time without having to run the report separately many times.

 

To further augment the flexibility of your reports, all reports and labels can be customized through event methods associated with the report or label and/or the report’s sections. These event methods are written in the Java language and you have full access to any Java class that is on your class path including the standard Java 2 classes, as well as any parameter, computed field, record source field, predefined variable, or built-in method defined in the report or label. In addition, you can define your own Java methods and variables in the Java code associated with the report or label. This provides you with the ability to extend the report or label to meet your needs even if we have not provided a built-in method or variable that meets your requirement.