Displaying DB fields with the help of the "Text" object

Top  Previous  Next

As you have seen, “Text” objects can display data from a DB as well as static text and expressions. We have also seen that it can be done in two ways: either by placing a link to the DB field into the object text, or by connecting the object to the required field through its “DataSet” and “DataField” properties. The first way is suitable for displaying both field contents and qualifying text in the same object. For example:

 

Contact person: [frxDBDataSet1."Contact_Person"]

 

Special syntax is required for links to the DB field: [datasetname.“fieldname”]. The field name (as well as the dataset name) can contain spaces but there must not be any space between the “point” and “quote” symbols.

 

Furthermore, we can also apply computing operations to a field in the expression, as shown here:

 

Length (cm): [<frxDBDataSet1."Length_in"> * 2.54]

 

Note how square and angle brackets have to be used. Remember that square brackets are used by default for delimiting expressions in the object’s text. Where required, the square brackets can be replaced by any other opening/closing character pairs (see the section “Displaying expression with the help of the “Text” object”). Angle brackets are used inside expressions for delineating the FastReport variables or DB fields. Logically we should write:

 

Contact person: [<frxDBDataSet1."Contact_Person">]

 

instead of

 

Contact person: [frxDBDataSet1."Contact_Person"]

 

However, both these notations are correct, as FastReport does not require angle brackets where the expression contains only a variable or only a DB field. In all other cases the angle brackets are required, as in:

 

Length (cm): [<frxDBDataSet1."Length_in"> * 2.54]