Summary
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.
Resolution
These are the basic steps that explain how to apply conditional formatting to objects on your report. They include:
- Basic and advanced conditional formatting
- To apply basic conditional formatting to a variable
- To apply advanced conditional formatting to a variable
- To save the changes to your document
This article assumes that you have located the report or layout that you want to amend and opened it in Sage Report Designer. If you need further help with this, please refer to the following article.
Basic and advanced conditional formatting
There are two methods of conditional formatting that you can use.
- Basic conditional formatting - Using this option you can set a filter, then from a list of format settings you can choose the format to apply when the filter is met.
- Advanced conditional formatting - Using this option you can enter an expression to determine what format applies when certain conditions are met. With this method you can apply more than one set of formatting to the object. For example, if you want an object to appear in red if one condition is met and to appear in blue if a different condition is met.
To select the type of conditional formatting to use:
- Tools > Options > amend the Use Advanced Conditional Formatting option as follows:
- To use the basic method - Clear the Use Advanced Conditional Formatting check box.
- To use the advanced method - Select the Use Advanced Conditional Formatting check box.
- Click OK.
To apply basic conditional formatting to a variable
- Select the required variable > Properties pane > Conditional Formatting > click the finder button
. - Filter tab > Edit > create the required filter > OK.
- Properties tab > set the properties to apply when the condition is met > OK.
To apply advanced conditional formatting to a variable
- Select the required variable > Properties pane > Conditional Formatting > click the finder button
. - Expression Editor window > enter the required expression > OK.
For information about the syntax used in advanced conditional formatting, please refer to the Detailed steps tab.
To save the changes to your document
- Report menu > Report Properties > enter a new name and description for the document > OK.
Report Designer v1.3 and below - Report Explorer pane > select the document name > Properties pane > Name > enter a new name for the document > Enter.
- File > Save As > File name > enter a new file name > browse to the required location for your document > Save.
- File > Exit.
The following detailed steps contain everything you need to help you to apply conditional formatting to objects on your report.
This article assumes that you have located the report or layout that you want to amend and opened it in Sage Report Designer. If you need further help with this, please refer to the following article.
Basic and advanced conditional formatting
There are two methods of conditional formatting that you can use.
- Basic conditional formatting - Using this option you can set a filter, then from a list of format settings you can choose the format to apply when the filter is met.
- Advanced conditional formatting - Using this option you can enter an expression to determine what format applies when certain conditions are met. With this method you can apply more than one set of formatting to the object. For example, if you want an object to appear in red if one condition is met and to appear in blue if a different condition is met.
To select the type of conditional formatting to use:
- From the Sage Report Designer menu bar, open the Tools menu and choose Options.
- In the Options tab, amend the Use Advanced Conditional Formatting option as follows:
- To use the basic method - Clear the Use Advanced Conditional Formatting check box.
- To use the advanced method - Select the Use Advanced Conditional Formatting check box.
- To confirm the changes click OK.
To apply basic conditional formatting to a variable
- Locate and select the variable to which you want to apply the conditional formatting, for example, SLCustomerAccounts.AccountBalance.
- From the Properties pane, select Conditional Formatting then click the finder button
.
- From the Filter tab, click Edit, create the filter to apply to the variable then click OK.
- 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.
- To confirm the conditional formatting, click OK.
- If required, to apply conditional formatting to further variables repeat the above steps.
You have now applied basic conditional formatting to objects on your report. You should make any further required changes and then save your report. For further information about saving your report, please refer to the section To save the changes to your document later in this article.
To apply advanced conditional formatting to a variable
- Locate and select the variable to which you want to apply the conditional formatting, for example, SLCustomerAccounts.AccountBalance.
- From the Properties pane, select Conditional Formatting then click the finder button
. - 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
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"; |
To save the changes to your document
- To save your changes, you must change the name and description of your document. To do this, open the Report menu, choose Report Properties, enter a new name and description for the document then click OK.
Report Designer v1.3 and below - To save your changes, you must change the name of your document. To do this, from the Report Explorer pane, select the document name. From the Properties pane, in the Name box, enter your preferred description for the document then press Enter. - To save the changes, open the File menu and choose Save As. From the Save As window, in the File name box, enter a file name for your amended document. If required, browse to the required location for your document then click Save. For further information about where to save your document, please refer to the following article.
- To close Sage Report Designer, open the File menu and choose Exit.
You have now saved your amended document.
Sage Business Partners can now log new cases online!
If you're unable to find the help you require from our online resources, log a new case with us without having to use phone or email. Simply select 'Manage your cases' from the dashboard or visit my.sage.co.uk/cases.
Sage 200 Services
Did you know Sage 200 customers now have access to a range of services direct with Sage. These include a bespoke Report Design Service, a library of How to Webinars and Ideas Portal just to name a few. Explore your potential using Sage 200 Services.