"Subject list" report
"Subject List" Report
Open Reports register and create a new report. Set report name to "Subject List". Open the designer by selecting the “Design...” menu item in wizard. In the designer click the “New report” button to automatically create a basic report design with three bands ("Report Title", "Master Data” and "Page Footer"). On tab "Data" drag and drop a “TfrxDlDBTable” object onto the workplace. Set property "TableName" to 'tHE_SetSubj'. In this table data about subjects are stored.
Now let’s design the report. First, add a “Text” object containing text "Subject List" to the "ReportTitle" band.
Next, connect the “MasterData” band to our dataset. This can done in any of three ways:
- double-click on the band
- select “Edit...” in the band’s contextual menu
- or click on the “DataSet” property of the band in the object inspector.
Now place four “Text” objects (which will display the subject name, address, phone and fax fields from the dataset) on the band. Let’s do this in several different ways to demonstrate some features of the designer.
The first way is to place a “Text” object on the band and type "[DlDBTable1."acSubject"]" into it. This is the least convenient way, since the field link has to be entered manually, with the possibility of incorrectly typing the text. Somewhat easier is to use the expression designer - double-click the “Text” object and click the leftmost button on the “Text” tab of the editor window which opens. To insert our field double-click the field name in the expression designer. Click the OK button to close the dialogue and see the field link inserted into the “Text” object.
The second way of adding the database field to the “Text” object is by setting two properties in the Object inspector. Place a second “Text” object on the band, without writing anything in the editor window. Set the object’s properties using the Object inspector:
DataSet = 'DlDBTable1'
DataField = 'acAddress'
Both of these properties are presented as a list, so just select the required value from the drop-down using the mouse.
The third way is to “drag and drop” the required field from the “Data tree” pane into the report. This is the simplest and easiest way, but before doing it uncheck the “Create header” checkbox at the bottom of the “Data tree” pane, otherwise a second “Text” object, containing the field’s name, is created in addition to the field link object itself. In this way select the “acPhone” field and drag it onto the band.
The fourth way requires the designer option “Show drop-down fields list” flag to be set (via main menu “View>Options”) and the band to be already connected to the dataset. Place a blank “Text” object on the band and hover the cursor over the object – a drop-down button will appear at the right hand end. Click this button to open the list of database fields and select the ”anFax” field.

Our report design is complete.

Click on the "Preview" button to see the result.

Aliases
In the previous report the data source was named DlDBTable1, the fields were named “acSubject,” “acAddress”, “acPhone,” and “acFax” and we referred to them in the report using something like "[DlDBTable1.“acSubject”]". Is this easy to understand? Not really. It would be clearer if the data source and the field were named “Subjects” and “Address” respectively. There is a problem, “DlDBTable1” is the name of the component, within which spaces are not supported and “acSubject” is the name of the field in the database, which cannot be changed without database restructure. However there is a way around this. We can use pseudonyms or aliases for these items. In FastReport both the dataset and its fields possess a second name property known as UserName, i.e. an alias, which can easily be changed. Whenever a component has been given an alias (i.e. UserName changed from its default), this alias must be used in FastReport - the component's Name property will not be recognized.
It is very easy to set aliases for a data source and its fields in FastReport. It is done in the Delphi environment. To open the alias editor, double-click on the "DlDBTable1" component or use its context menu. You can modify the dataset and field aliases in the editor, and also specify which fields are needed in the report. Let's rename the dataset and fields as below:

The alias for the dataset can also be modified without using the alias editor, changing the “UserName” property of the "DlDBTable1" component.
Having done this we now need to modify the report, as the names of the dataset and fields have been changed. To modify the field names in report objects, it is easiest to use the fourth method described in the "Subject List" report" section. Move the mouse cursor over the “Text” object so that the button in the right hand end of the object appears, click on the button and select the field from the list. Following this the origin of the data in the dataset and its fields is more apparent.
Note: It is better to assign aliases at the very beginning of report design to avoid having to later rename all the fields within a report.
Variables
As well as aliases, there is another way to help the report designer set more understandable names for DB fields and other information elements. A database field name or any expression can be associated with a variable. To create and work with variables in FastReport, select the “Report/Variables...” menu item.
The list of variables in FastReport has a two-level structure. The first level simply contains the category and the second level contains the variable itself. This categorization of variables is convenient when the list of variables is very long. A variable list must contain at least one category, which means that variables cannot be located at the top level. Furthermore, category names cannot be included in reports, so each name within the list must be unique.
Let's illustrate the use of variables with the following example. Assume we have two data sources: the first is “DlDBTable1” with “acSubject” field and the second is “DlDBTable2” with “OrderNo” and “Date” fields. We can associate the following list of variables with the fields:
Clients
Client name
Orders
Order number
Order date
where “Clients” and “Orders” are two categories. Open the variables editor and create this structure by using of the “New category”, “New variable”, and “Edit” buttons. To link the variables to the database fields select a variable and double-click on the required database field in the right hand pane. The link to the database field will be shown in the bottom pane. The variable is now associated with this expression so the value of the variable becomes the value of the expression. If necessary, the expression can be edited or modified manually and any FastReport functions or other variables can be used within it. Remember that categories must not be associated with any expression.

After the list of variables has been created, close the variables editor. Now we can insert the variables into the report. In contrast to database fields, there are fewer insertion methods. We can either insert a variable into the object text manually by typing “[Client name]”, or we can drag a variable from the Data tree pane onto the report page, in which case switch to the “Variables” tab in this pane.