Body Groups & Totals


Defines headings, sub-totals and grand totals for form bodies. Only Variable Height - Report style form bodies use these properties.

Type

Heading

Prints a heading at the top of a body every time the evaluation of the expression in Group changes. The heading is specified in the Label field.

Subtotal

Prints a sub-total every time the evaluation of the expression in Group changes.

Grand Total

Prints a grand total at the bottom of the body when it has finished printing.

Formatting

Label

Enter a text string to appear as the heading if a Heading type is specified, or the text to appear to the left of a Subtotal or Grand Total. Labels are optional except for headings. If no text is placed in the Label field for a Heading, it will not print.

Align With

Enter the body field to align the Heading or Total with. If no alignment is specified the heading or total is aligned left of the first body field.

Row Height

The height in screen (pixel) units of the Heading or Total. This will default to the same size as a regular body line. You can increase this to allow for more space between body lines and headings or totals.

generate/hint1.gif You should increase the width if you will be using a larger font for this section. If the heading or total appears cut-off or is not visible at all, try increasing the row height.

Keep With Previous

If this checkbox is ticked the current group is vertically aligned with the previously printed group. It also adopts the font size and colour of the previous group. This would be useful if you wished to show, for example, a price and quantity total on the same line.

generate/mistake2.gifDo not mark Keep With Previous if more than one heading, subtotal or total is to appear under the same column. The last group displayed would then overwrite the previous one. This is a common mistake when assigning subtotals and totals.

Page Break

If this checkbox is ticked printing will stop on the current page and carry over to the next page. If the group is a heading, the page break occurs just before the heading is printed. The heading will then appear at the top of the following page. This would be useful if you did not wish to print more than one grouping on the same page.

If the group is a subtotal or a grand total, then a page break occurs immediately after the subtotal or grand total is printed.

Defining Formulas

Group

When the body field or expression specified is changed, the printing of a subtotal or heading is triggered. The Group has no effect on Grand Totals.

It is important to sort the body on the same field or fields defined in the Group. If this isn't done the printing of the heading will occur arbitrarily. Consider the following expression:

Stock->Type

The Type field refers to the stock group code and Stock-> refers to the stock database. If the above was defined as the Group field, then a heading would be printed each time the stock group changed. If the body being printed is sorted by the stock group, each heading only gets printed once. In the following list of stock items only the product code and stock group are shown:

ABC123B

FRIDGE

J456B

DISHWASH

M317/C

OVEN

Q23B

FRIDGE

R231

OVEN

R231

OVEN

Z1311

DISHWASH

Because the list is sorted by product code, the ordering of the stock group changes 5 times. This would cause 5 headings to be printed. Consider the same list sorted by stock group:

J456B

DISKWASH

Z1311

DISHWASH

ABC123B

FRIDGE

Q23B

FRIDGE

M317/C

OVEN

R231

OVEN

R231

OVEN

Since the stock group sequence now only changes 3 times, headings will only be printed 3 times. More importantly, the same headings will not be repeated.

For more information on defining expressions see: CAPITAL Business Script.

generate/hint1.gifAdvanced Feature Tip

It is also possible to define special conditions in groupings. This can be done using the IF() function. The following expression will create a grouping based on transactions that occur before the current date and after the current date. Note that if the report is not sorted by date sequence, grouping will not work correctly.

IF(Job->DueDate < Today(), '1', '2')

This expression will return the value "1" until the date defined by the field Job->DueDate is no longer less than the function Today(). When the due date is equal to today or later, the value "2" is returned.

Display

This field is optional. If you are defining a Heading and leave this blank, the Label field will be printed. You can combine a label with a database field by defining a CBS expression. For example:

Label + ' ' + Type->Name

In the above example Label is the name used to refer to the text entered in the Label field. The + means join with. The Label text is printed first, then the string ' ' (a single blank space), then the contents of the database field: Type->Name.

For numeric totals you can control the size, rounding, and other formatting issues relating to the numbers displayed using the STR(value, length, decimals) function. For example:

Label + ' ' + Str(TotalSales, 10, 2)

The Str() function would print the variable TotalSales 10 characters wide, and with 2 decimal places.

For more information on this topic see: CAPITAL Business Script.

Result In

Specify a variable name to hold the subtotal or grand total value. A variable name has 10 significant characters (your variables may be longer than 10 characters but CAPITAL will ignore anything beyond 10) and is made up of letters and/or numbers. A variable name must start with a letter of the alphabet.

Equation

The calculation to perform. An expression used to perform a calculation usually has a format similar to this:

TotalCost + Stock->A

The above calculation assumes that the Result In field contains the variable name TotalCost. The actual calculation becomes:

TotalCost = TotalCost + Stock->A.

To determine if the a calculation has been correctly defined, press the Test button.

Group Ordering

Use the generate/up1.gif generate/down1.gif buttons on the group list tab to control the ordering of groups. Select a group you wish to move and press on either button to move it up or down the list. Unless you have a special reason to do otherwise, the following general arrangement is recommended for a sensible presentation:

1. Place sub-totals at the top of the list.

2. Place grand totals below sub-totals.

3. Place group headings at the end of the list.

4. Place groups that appear more frequently before less frequent groups. For example, a sub-sub-total should generally appear on the list before a sub-total.



CAPITAL VISUAL BUILDER