40.5 Add Vertical Space Between Records

To make the report more readable, you can add space between a certain number of records. To do so, you first create the parameter that determines the number of records between which the space will display. Then, you create a summary column in the data model that counts the number of records. You will then modify the paper layout of your report so that the vertical elasticity is variable. Finally, you will create a format trigger that will display the space between the user-determined number of records.

40.5.1 Create a user parameter

The parameter you will create in this section will determine how many records are displayed before an extra space is printed. Since this parameter is a user parameter, the user can change this value at runtime.

To create a user parameter:

  1. In the Object Navigator, under the Data Model node, click the User Parameters node.

  2. Choose Edit > Create to create a new user parameter under the User Parameters node.

  3. If the Property Inspector is not already displayed, right-click the new user parameter (P_1), then choose Property Inspector to display the Property Inspector, and set the following properties:

    • Under General Information, set the Name property to SPACE.

    • Under Parameter, set the Datatype property to Number, and set the Initial Value property to 5.

      Note:

      By giving the user parameter an initial value, the user can simply run the report without changing the parameters, and a space will display between every five records.

    The user parameter now displays in the Object Navigator:

    Figure 40-13 User Parameter in the Object Navigator

    Description of Figure 40-13 follows
    Description of "Figure 40-13 User Parameter in the Object Navigator"

  4. Save your report.

40.5.2 Create a summary column that counts the number of records

In this section, you will create a summary column in the data model that counts the number of employee records. This information will then be used by the format trigger to determine where to add extra space.

To create a summary column:

  1. In the Object Navigator, double-click the view icon next to the Data Model node to display the Data Model view.

  2. In the Data Model view, click the Summary Column tool in the tool palette, then click in the G_FIRST_NAME group beneath the TOTAL_COMP formula column to create a new summary column:

    Figure 40-14 Data Model with new summary column

    Description of Figure 40-14 follows
    Description of "Figure 40-14 Data Model with new summary column"

  3. Double-click the new summary column object (CS_1) to display the Property Inspector, and set the following properties:

    • Under General Information, set the Name property to CNT_COLUMN.

    • Under Summary, set the Function property to Count, and set the Source property to FIRST_NAME.

  4. Save your report.

40.5.3 Modify the layout

To allow Reports Builder to insert the vertical spacing, you must modify the layout of your report.

To add vertical elasticity:

  1. Click the Paper Layout button in the toolbar to display the Paper Layout view.

  2. Click the Flex On button in the toolbar.

  3. In the Paper Layout view, click the repeating frame associated with G_FIRST_NAME.

    Note:

    If you cannot find the repeating frame in the Paper Layout view, you can click R_G_FIRST_NAME in the Object Navigator. The associated repeating frame will be selected in the Paper Layout view.

  4. Click the center handle of the frame and drag the frame downward to create additional space. This additional space should be slightly larger than what you want to see between the sets of records.

  5. With the repeating frame selected, choose Tools > Property Inspector to display the Property Inspector, and set the following properties:

    • Under General Layout, set the Vertical Elasticity property to Variable.

  6. In the Paper Layout view, click the Rectangle tool in the tool palette, and draw a rectangle below the fields in the newly created space.

  7. Make sure the new rectangle has no fill and no line so that it is not visible.

    The following image shows the new layout with the invisible rectangle:

    Figure 40-15 Layout with added vertical space

    Description of Figure 40-15 follows
    Description of "Figure 40-15 Layout with added vertical space"

  8. Save your report.

40.5.4 Create a format trigger

Now that you have adjusted the layout, you can create a format trigger based on the new boilerplate rectangle you created in the previous section. This format trigger will display this space after every set number of records, determined by the user parameter.

To create a format trigger on the boilerplate rectangle:

  1. While the rectangle is selected in the Paper Layout view, press F11 on your keyboard (or choose Tools > PL/SQL Editor) to display the PL/SQL Editor.

  2. In the PL/SQL Editor, use the template to enter the following PL/SQL code:

    function B_1FormatTrigger return boolean is
    begin
     If :CNT_COLUMN mod :SPACE = 0 then
       return(TRUE);
     else
       return(FALSE);
     end if;
    end;
    

    Note:

    You can enter this code by copying and pasting it from the provided text file called plsql_code.txt. This code is for the Format Trigger.

  3. Click Compile.

  4. When the code is compiled without errors, click Close.

  5. Save your report.