File: ...\Samples\Solution\Reports\Colors.frx
This sample report demonstrates how you can use Print When conditions for controls to change field formatting based on the values in the record. The sample prints a "Product Inventory Report." If the product item is discontinued, it is printed in strikeout. If the In Stock amount is below the reorder level and the product is not discontinued, the item is printed in red. Otherwise, the product item is printed in standard black.
This report uses the table, PRODUCTS, from the database, TESTDATA, in the Data Environment. The Detail band has field controls for the product information such as ID, name, amount in stock, and amount on order. Another field control prints a reminder when the stock goes below a set reorder amount.
To handle the three cases, three sets of field controls for the product information are layered on top of each other in the Detail band. For the first set, the text color is red; for the second, the color is black; and for the third, the font effect is Strikeout.
Each control set has a different Print When expression.
-
For the plain black fields:
В Copy Code (products.in_stock > products.reorder_at) and products.discontinu = .F.
-
For the strikeout fields:
В Copy Code products.discontinu = .T.
-
For the red text color fields:
В Copy Code products.in_stock <= products.reorder_at and products.discontinu = .F.