I have come across a situation in Crystal Report. Suppose for example I have two tables Employees and Departments.
An Employee can be belonged to two departments. In the report I need some thing like this

Report Output
I don’t want to insert any group. Just a list of employees with their corresponding Departments
Solution:
To achieve this in crystal report we need to write some formula.
Formula 1: @Department
WhilePrintingRecords;
Shared StringVar Result;
if(NextIsNull({Employees.EMPID})=true or
{Employees.EMPID }<>Next({Employees.EMPID })) then
Result:={Departments.Name}
else
Result:={Departments.Name }& “,” & chr(13)& Next({Departments.Name })
Place the @Departments formula in the details section. Now you will get the output like this.

Report Output
We need to eliminate the second row and fourth row. For that we need to do
- Right click the EMP.ID field in the details section and select Suppress if duplicated option.
- Now select the EMP.Name and @Departments fields. Right click and select Format Field . In the common tab check Suppress.
- In the X2 formula section of the Suppress write this formula.
WhilePrintingRecords;
if(PreviousIsNull({Employees.EMPID})=true or {Employees.EMPID}<>
Previous({Employees.EMPID})) then
false
else
true
- Now whole second row and fourth row are appearing blank.
- To eliminate that space, Right click details section and select Section Expert.
- Check the Suppress blank section option.
If anybody founds any other way achieve this, can post the things here.
Happy Coding!!
[...] Report; Business Objects – Get Crystal Report 2008 Prompts using InfoStore from CMS Repository; Comma separated Column value in Crystal Report; Useful Links: Excel-like Web-based Java Reporting Software; Freezea’s Report Lesson; [...]
By: Export image format PDF files with page break in web reporting tool | RAQSOFT on April 21, 2009
at 2:42 pm
[...] Report; Business Objects – Get Crystal Report 2008 Prompts using InfoStore from CMS Repository; Comma separated Column value in Crystal Report; Useful Links: Excel-like Web-based Java Reporting Software; Freezea’s Report Lesson; [...]
By: Export image format PDF files with page break in web reporting tool - RAQSOFT Konw How on April 21, 2009
at 2:45 pm
How will be if you have MANY departments. In another word, not only 2, for X.
Thank you.
By: Santiago on August 13, 2009
at 10:18 pm