4D v13.4

An example report

Home

 
4D v13.4
An example report

An example report  


 

 

This section describes an example report and shows how the finished report is related to a form in the Form editor and to the methods that control the printing.

The following illustration shows a finished report:

In this example, the page Header contains the date, the time, and the report title. The Break Headers contain the customer name and column headings for the information presented during the first Break. The Detail areas contain data drawn directly from the records. The level 2 Break areas contain subtotals for products for each customer. The level 1 Break areas contain subtotals for each customer and the level 0 Break area contains a total for the report. The Footer contains the page number.

The report is sorted on one more level than Break levels. In this report, the sorted fields are Customer, Product, and Date.

The following illustration shows the report form that created the report shown on the previous page:

Each control line in the form defines the bottom of its area. Whatever is placed in the form is printed at the appropriate place in the report. The Header area contains the elements that will be printed at the top of each page, the Detail area contains the elements that will be printed for each record, and so on. 

The following table shows what each of these control lines means.

LabelExplanationEffect
HHeader areaPrinted once at the top of each page
H1L1 Header areaPrinted once before each level 1 Break
H2L2 Header areaPrinted once before each level 2 Break
DDetail areaPrinted once for each record in the selection
B2L2 Break areaPrinted once at each level 2 Break (when the value in the second Sorted field changes)
B1L1 Break areaPrinted once at each level 1 Break (when the value in the first Sorted field changes)
B0L0 Break areaPrinted once at the end of the report
FFooter areaPrinted once at the bottom of each page

The non-enterable objects that are placed in the Header, Break, and Footer areas are controlled by object methods.

Note: The following code can be used only in object and form methods. It cannot be used in project methods.

The date is drawn from the system date by placing a non-enterable object named vDate in the Header area with this method:

 vDate:=Current date

The time is drawn from the system clock by placing a non-enterable object named vTime in the Header area with this method:

 vTime:=Current time

The subtotal for sales in the level 2 Break area is calculated and displayed in an object named vSalesProd with the following method:

 vSalesProd:=Subtotal(Sales)

The subtotal for sales in the level 1 Break area is calculated and displayed in an object named vSalesCust with the following method:

 vSalesCust:=Subtotal(Sales)

The total for sales in the level 0 Break area is calculated and displayed in an object named vSalesTotal with the following method:

 vSalesTotal:=Subtotal(Sales)

Note that even though all three objects use the same calculation, they produce different results. Because they are placed in different Break areas, they are executed at different times and perform their calculations for different groups of records. For an explanation of Break levels, see the “Using breaks” section in Forms for printed reports.

 vPage:="Page "+String(FORM Get current page)

The FORM Get current page function returns the page number.

 
PROPERTIES 

Product: 4D
Theme: Output forms and reports