In this article, we will learn conditional formatting on Field in Crystal Reports. Will display the salary of each employee and highlight the row if the salary is greater than 25,000 in red.
If you haven’t had a look at the first, then please go through the previous article: Step By Step Creating Grouping In Crystal Report.
Step 1: Create a new Table Salary as in the following:
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE TABLE [dbo].[Salary](
- [EmpId] [int] NULL,
- [Salary] [numeric](18, 2) NULL
- ) ON [PRIMARY]
- GO
We already created 2 tables in my first article which is Employee and Department. So now we have 3 tables, [1] Employee [2] Department and [3] Salary,
Step 2: Now open the Crystal Report, go to Field Explorer, right click and select Database expert like the following screen:
Step 3: from the database Expert select the Salary table and click on ‘>’ button and click ‘OK’ Button,
Step 5: Now we have salary table in Field Explorer
Just Drag and Drop Salary field in Details Section of Crystal Report,
Step 6: Now go to Crystal Reports tab, Report and select Section Expert,
Step 8: Click on the highlighted button, this will open Formula Workshop,
Step 9: Write your condition here like the following:
if {Salary.Salary} > 25000 then
crRed
else
CrSilver
(If the salary is greater then 25000 then highlight the row with red color else silver color),
That’s it! Just check the formula by pressing Alt + C for checking for errors like the following screenshot,
No comments:
Post a Comment