Sage 200 Report Designer - How to apply conditional formatting to a variable
Description

One of the features of Sage Report Designer is the ability to format objects in a certain way, depending on specific conditions. For example, you can choose to display all customer balances over £1000 in red. This article explains how to apply conditional formatting to a variable.

TIP: An alternative to conditional formatting is to use If statement expressions. For further information about this, please refer to this article.

Cause
Resolution

The following steps contain everything you need to help you to apply conditional formatting to objects on your report.

Note: If any of the panes mentioned in this section are not visible, open the View menu and select the required pane. If the pane doesn't appear, you can reset the Report Designer view to its default through Tools > Options > Reset settings.

To apply basic conditional formatting to a variable

  1. Locate and select the variable to which you want to apply the conditional formatting, for example, SLCustomerAccounts.AccountBalance.
  2. From the Properties pane, select Conditional Formatting then click the finder button .

    Note: Using the Filter tab you can create the filter on which to base the condition. Using the Properties tab you can define the effects of this condition, for example, change the font colour.

  3. From the Filter tab, click Edit; create the filter to apply to the variable then click OK.

    For further information about building filters, please refer to article 30844.

    Note: When using dates within conditional formatting, you must enter the date in the format #yyyy/mm/dd#, for example, #2010/05/13#.

  4. Click the Properties tab and set the properties to apply when the condition is met. For example, to show any values in red, expand the Text Style option and from the Color drop-down list, choose Red.

    Tip: The preview pane indicates how the object appears when the condition is met.

  5. To confirm the conditional formatting, click OK.

To apply advanced conditional formatting to a variable

Note: Before following the steps in this section you should check that Report Designer is set to use advanced conditional formatting. To do this, go to the Tools menu and choose Options. Select the Use Advanced Conditional Formatting check box. The syntax will only function correctly when this check box is selected.

  1. Locate and select the variable to which you want to apply the conditional formatting, for example, SLCustomerAccounts.AccountBalance.
  2. From the Properties pane, select Conditional Formatting then click the finder button .
  3. In the Expression Editor window, enter your conditional formatting expression, then click OK.

For information about the syntax used in advanced conditional formatting, please refer to the following section.

Syntax guide for advanced conditional formatting

When Advanced Conditional Formatting is selected, the Conditional Formatting window is replaced by the Expression Editor window which requires the condition to be entered as code. The code uses the following format:
if condition to be met, for example, SLCustomerAccounts.AccountBalance > SLCustomerAccounts.CreditLimit then

begin
the formatting to apply, for example, TextStyle->Color := NamedColor("Red");
end

This would be shown in Report Designer as:

if SLCustomerAccounts.AccountBalance > SLCustomerAccounts.CreditLimit then

begin

TextStyle->Color := NamedColor("Red");

end
You can create multiple conditions by using an else statement to separate each individual condition, for example:
if (SLCustomerAccounts.AccountBalance > 1000 and SLCustomerAccounts.AccountBalance <= 5000) then

begin
TextStyle->Color := NamedColor("DarkOrange");
end

else

if SLCustomerAccounts.AccountBalance > 5000 then

begin
TextStyle->Color := NamedColor("Red");
end

The table below shows some common formatting code examples.

To change... Syntax
Text Colour TextStyle->Color := NamedColor("InsertColour");
Bold TextStyle->Bold := True;
Italic TextStyle->Italic := True;
Strikeout TextStyle->Strikeout := True;
Underline TextStyle->Underline := "Double";
Overline TextStyle->Overline := "Double";
Style Formatting := FormattingStyle("Small Heading");
Suppress Printing SuppressPrinting := True;
Autogrow AutoGrow := True;
Wordwrap WordWrap := False;
Locked Locked := True;
Visible Visible := False;
Font TextStyle->FontName := "Arial";
Print On First Copy Only PrintOnFirstCopyOnly := True;
Horizontal Alignment TextStyle->Alignment := "Right";
Vertical Alignment TextStyle->VerticalAlignment := "Bottom";

 

Steps to duplicate
Related Solutions