Among major tools, features and enhancements, R:BASE Turbo V-8 for Windows and R:BASE V-8 "Turbo" for Windows include the sub-reports to empower the reporting capabilities of R:BASE. You can place the Sub-Report control by selecting the Sub-Report icon on the Advanced Controls in Report Designer.

UnderstandingSubReports_01

Sub-Report control in Report Designer provides three different capabilities based on the value of the Print Behavior property, i.e., Fixed, Child and Section. The default is set to Child. To access the Print Behavior property of Sub-Report, simply right-click on the Sub-Report object placed on the report to access all options on speed menu.

UnderstandingSubReports_02

When Print Behavior is set to Fixed, the dimensions of the Sub-Report control are used as the page size of the report. The report generates a single page fitted to these dimensions. This setting is most often used when a report of fixed size, such as a table, needs to be printed at a pre-defined location on the page.

When Print Behavior is set to Child (the default), the width of the Sub-Report control is used as the page width and the page height of the parent report is used (as specified in the parent report's Printer Setup property). The report begins printing at the first available location on the page and then 'stretches' across as many pages as are necessary to complete the report. Sub-Reports set to Child behave like stretching memos and are well-suited for most 'multiple detail band' requirements. Because child reports use the width of the Sub-Report control as the page width, they are also useful for some side-by-side reporting effects.

Note:
When creating child type sub-reports, you must set the parent band Print Height to Dynamic; otherwise, the report will not print.


When Print Behavior is set to Section, the Sub-Report uses its own Printer Setup property to determine the page dimensions. When the report completes printing, the last page is completed and control is returned to the parent report at the beginning of the next page. When several
independent reports need to be 'chained' together, Section Sub-Reports are generally the best choice. (Note: In order to link several reports together, place each subsequent Sub-Report in the Summary Band of the preceding report.)

Section type Sub-Reports also have the capacity to change the printer settings for the portion of the report in which they generate. Use the Sub-Report's Printer Setup property to specify the different settings, just as you would a normal report. If you specify a different printer in Printer Setup than that of the parent report, then a New Print Job will be started on that printer when the report generates. This means that different sections of a report can not only use different printer settings, but that they can also be sent to different printers.

Tip:
In order to keep section type Sub-Reports from taking up any space in the parent report, place the Sub-Report in a band by itself and set the Band's Print Height property to Dynamic.


Summary:

The value of the Print Behavior property determines how a sub-report prints within the master report. There are three possible values:

Sub-Report Option
Meaning
Fixed
A single page prints based on the dimensions and position of the sub-report object placed on the report.
Child
The report prints to completion, using the sub-report controls width as the page width and stretching over several pages until printing is complete.
Section
The report prints as a separate section, starting a new page when it begins and finishing the last page when it ends. The Printer Setup property is used to determine the page size and printer settings.


Note:
When creating child type sub-reports, you must set the parent band Print Height to Dynamic; otherwise, the report will not print.

Tip:
Each sub-report tab must be associated with a slave table. Slave table(s) may be added by selecting Add/Remove Tables... option of Tables from the Report Designer Menu Bar.

Report Designer | Main Menu | Tables | Add/Remove Tables...

UnderstandingSubReports_04

UnderstandingSubReports_05

Use Report Designer's Edit Control to assign a table to specific sub-report:

When selecting the Sub-Report control from Advanced Controls in Report Designer, placing the object on desired band, two tabs will be displayed at the bottom of the workspace: Main and SubReport1 associated with appropriate tables. There is a separate workspace for the main and for each sub-report. You can access the workspace for any given report by simply clicking on the tab. Each additional sub-report will have its own tab associated with corresponding table.


UnderstandingSubReports_06


Additional Sub-Report Properties:

   Align...
   Component ID
   Bring To Front
   Send to Back
   Drill Down
   Expand All
   Keep Together
   New Print Job
   Parent Printer Setup
   Parent Width
   Position ...
   ReprintOnOverFlow
   ResetPageNo
   ShiftRelativeTo ...
   ShiftWithParent
   Stretch
   Traverse All Data
   Visible

Align...

The Alignment property specifies how text is aligned within the control. There are three possible options:

Left Justify    Align text to the left side of the control
Center         Center text horizontally in the control
Right Justify   Align text to the right side of the control

Component ID:

Use this option to assign a Component ID to dynamically get and assign the control properties using the PROPERTY and GETPROPERTY commands.

Bring To Front:

The Bring To Front method places the report control in front of all other report controls within the same band.

Send To Back:

The Send To Back method places the report control behind all other report controls within the same band.

Drill Down:

Sub-Report control properties also include the option of Drill Down. This property applies to sub-reports that have the Print Behavior set to Child. When assigned, this property indicates the 'hot' control which, when clicked, causes the current page in the Print Preview window to be regenerated with the sub-report expanded. This creates the effect of a 'drill-down' sub-report.

Expand All:

This property applies to sub-reports that have the Print Behavior set to Child and the Drill Down property set to true (checked). When set to True, all instances of the sub-report print are expanded. The drill-down component is no longer 'hot' in the print preview window.

Keep Together:

The Keep Together property controls the pagination of a Child type Sub-Report when the contents cannot fit on the current page. Normally the contents are printed to the bottom of the available page space and then continued on subsequent pages until complete. If Keep Together is True (checked) , the Sub-Report will advance to the next page when the contents do not fit. The default is set to true (checked).

Use ResetPageNo to enable subset page numbering. In subset page numbers, the page numbers and page count of the sub-report are displayed instead of the master report page numbers. ResetPageNo is only available in Section style sub-reports.

New Print Job:

When the Print Behavior (Child, Fixed, Section) property is set to Section, this property determines whether a new print job is started when the sub-report is sent to the printer. This property can be used when a portion of a report needs to be printed to a separate printer. If you need to change printer settings for a certain section, you can do so without starting a new print job. Simply set the value of the appropriate Printer Setup properties (Orientation, Paper Name, Bin Name, etc.) and these settings will be applied as the report prints.

Parent Printer Setup:

This property determines whether the values for the Printer Setup property should be copied from the parent report. If Parent Printer Setup is False (unchecked), then one or more of the Printer Setup properties differ from the parent report.

Parent Width:

When set to True (checked), this property forces the width of the control to match width of the parent control. The parent may be either a band or a region.

Position...

This is the vertical position on the page for this stretchable Sub-Report control. Before the control is generated, this is the starting position (Left, Top, Width, Height); after the control is generated, this is the ending position.

Use the Bottom Offset property to define the vertical space that should appear after the sub-report control has printed. The Bottom Offset is expressed in report units.

Note:
The Bottom Offset acts as a margin between the stretching control and the controls that are shifting or stretching in relation to it.

Use the OverFlow Offset property to define the vertical space that should be above the control when it is overflowing onto an additional page. The OverFlow Offset is expressed in report units.

Note:
The OverFlow Offset acts as a margin between the stretching control and the top of the page.

Use the Stop Position property to define the vertical position at which the stretchable will stop printing. The Stop Position is expressed in report units.

Notes:
Together with the Top and OverFlow Offset properties, the Stop Position can be used to restrict a stretchable control to a certain position on the page. This is often useful when you are printing on pre-printed forms and need to print information within a certain rectangular area on the page.

For sub-reports, this property applies only to sub-reports that have the Print Behavior set to Child.

ReprintOnOverFlow:

For stretchable controls that are not stretching, this property allows you to reprint the control when other stretching controls in the band or region overflow to a new page. The default is set to false (unchecked). To set the ReprintOnOverFlow property from the Report Designer, position your mouse cursor over the control and click the right mouse button. The ReprintOnOverFlow option will be displayed in the speed menu. If it is checked, ReprintOnOverFlow is on. Selecting the ReprintOnOverFlow option from this menu will toggle its value.

Reset Page No:

Use Reset Page No property to enable subset page numbering. In subset page numbers, the page numbers and page count of the sub-report are displayed instead of the master report page numbers. Reset Page No is only available in Section style sub-reports.
   
ShiftRelativeTo...

When multiple stretching controls occupy the same band, use this property to specify how each control should be positioned relative to other stretching controls. ShiftRelativeTo can only be used for controls that are dynamically sized. If you have a static control, such as a label, which needs to shift relative to a given stretching control, then place the control in a region and set the Region's ShiftRelativeTo to the stretching control.

Notes:
When stretching controls are placed within a region, the ShiftRelativeTo property is disabled. You may notice that all of the stretching controls in the band do not always appear in the ShiftRelativeTo dialog when you are assigning this property. This is due to validation logic, which ensures that controls which are shifting relative to one another are not involved in a circular reference. In other words, if Memo1 is shifting relative to Memo2, then Memo2 cannot shift relative to Memo1, as this would create a situation which the report engine could not resolve.

ShiftWithParent:

This property applies to situations where a Stretchable control is stretching. If ShiftWithParent is set to True (checked), the report control will move based on the amount of stretching the memo requires. When you want controls to appear at the bottom of a memo, this is a useful feature. If the memo stretches to a new page, the controls will print on the next page. The default is set to False (unchecked). To set the ShiftWithParent property from the Report Designer, position your mouse cursor over the control and click the right mouse button. The ShiftWithParent option will be displayed in the speed menu. If it is checked, ShiftWithParent is on. Selecting the ShiftWithParent option from this menu will toggle its value.

Stretch:

The Stretch property determines whether the Height of the memo automatically stretches to allow the entire contents of the memo to be printed. The default is set to False (unchecked). To set the Stretch property from the Report Designer, position your mouse cursor over the control and click the right mouse button. The Stretch option should be near the bottom of the speed menu. If it is checked, the memo will stretch, overflowing to additional pages if necessary. Selecting the Stretch option from this menu will toggle its value.

Traverse All Data:

This property applies to sub-reports that have the Print Behavior set to Fixed. When set to True (checked), this property indicates that the sub-report will continue to print (print on additional pages in the same exact position) until all data is traversed. By default the fixed type sub-report truncates the data (i.e., prints once per band, but does not overflow if all data can't fit in the space of the sub-report).

Visible:

The Visible property determines whether a report control will be printed. You can conditionally print a report control by setting the Visible property at run-time using the PROPERTY command. You can suppress the printing of an entire band by setting the Visible property of each report control to False. If the Print Height property of the report band is set to Static, then blank white space equivalent to the height of the band will be printed. If Print Height is set to Dynamic, no page space is used and the next band begins printing. If you want to suppress an entire band, it is usually best to use the Visible property of the band itself.

To set the Visible property from the Report Designer, position your mouse cursor over the control and click the right mouse button. The Visible option should be near the bottom of the speed menu. If it is checked, the control will be printed. Selecting the Visible option from this menu will toggle its value.

                                    
Sample Reports:

Please refer to CustContInvoices and CustomerContacts reports included with Running R:BASE Your Way! (Part 10), a sample database and application to demonstrate the use of Sub-Reports.