Top  Previous  Next

In the previous report the data source was named frxDBDataSet1, the fields were named “CustNo,” “Company,” “Phone,” and “FAX” and we referred to them in the report using something like "[frxDBDataSet1.“CustNo"”]". Is this easy to understand? Not really. It would be clearer if the data source and the field were named “Our clients” and “Number” respectively. There is a problem, “frxDBDataSet1” is the name of the component, within which spaces are not supported and “CustNo” 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 frxDBDataSet1 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 frxDBDataSet1 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 ""Customer 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.