Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

7.19 Default Attribute and Current Field Value

Using the Default Attribute and Current Field Value

The value assigned to a property in design mode is called the property’s default attribute. When assigning a formula to that property, the default value is overridden by what is in the formula. There are many times when a formula is only used to specify what happens in a unique circumstance (e.g. an inventory item being out of stock) and you don’t want the formula to override the default value each time. You want the default property value to be left unchanged. To use the current property value without overriding it, return the DefaultAttribute keyword.

For example, let’s set the Inventory On Hand field to be red if its value is less than the minimum quantity. Otherwise, use the default attribute to leave it the color specified in the Format Editor. You can use a formula like the following:

If {Inventory.OnHand} < {InventoryItems.MinimumQty} Then
crRed
Else
DefaultAttribute;