Crystal Reports - Suppress Non-Consecutive Duplicates in Group

Melisa B
Melisa B used Ask the Experts™
on
I'm working on building a report that pulls name data based on a specific report identification number. I have the information grouped by the report number and want to display names related to the report. The problem is that each report number can/often does have subsequent reports written that are attached to the same number which include the same names, thus giving me duplicate names in the group, but not listed consecutively. The report looks like this currently:

Report #                Name
170001                   Smith, Bob
                                Doe, John
                                Doe, Jane
                                Smith, Bob
                                Doe, John
                                Doe, Jane
170002                   Jones, Mike
170003                   White, James
                                White, Jack
                                White, James

I want to suppress all instances where there are duplicate names under the same report number.

Thanks in advance for any help!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
Is there a reason you can't sort by the name and make the list easier to produce?

Is there other information on the line or just the names?

You can do this b building an array of names that have been displayed then suppress based on that

Try this idea
In the report header add a formula
Name - DeclareVariables
WhilePrintingRecords;
Global StringVar Array NamesList;
Global NumberVar ListSize;
ListSize := 0;
ReDim NamesList[1];
''

Open in new window


Put the DeclareVariables formula in the Report# Group header also.

In the details section add a formula
Name - BuildandCheckList

WhilePrintingRecords;
Global StringVar Array NamesList;
Global NumberVar ListSize;
Local NumberVar Index;
Local BooleanVar NameFound;
NameFound := False;

For Index := 1 to ListSize do
    If {NameField} = NamesList[Index] then
        NameFound := True;

If NameFound = False then
(
    ListSize := ListSize + 1;
    ReDim Preserve NamesList[ListSize];
    NamesList[ListSize] := {NameFIeld};
)
Else
    ''

Open in new window


In the section expert for the detail section check the box for SUPPRESS BLANK SECTION

mlmcc

Author

Commented:
The report has the following headers/information:
Report #
Date
Report Type
Location
Make (of Vehicle)
Style (of Vehicle)
Type (for the person listed, this includes codes for the following - suspect, defendant, arrested party)
Name (of the suspect, defendant, arrested party - suspect if they're named, defendant if they're identified in the course of the investigation, arrested party if they're actually arrested for the crime)

The report is grouped by report number so that I avoid duplicates on those - each report can have anywhere from just the original report to several supplemental reports with duplicate information on everything except the actual narrative, so I run into this problem A LOT. The formulas you gave me worked beautifully, but now I can't suppress "blank" sections because of the "Type", since if there are 2 suspects listed, the code shows for each listed suspect name AND the code is there for those blank suspect name fields...so it looks like this:

11111            01/13/17             AUTO THEFT          123 MAIN ST           CHEV/LL        SUS          SMITH,CARL
                                                                                                                                             SUS          SMITH,MARIA
                                                                                                                                             SUS
                                                                                                                                             SUS

because the suspects are listed in both the original and the supplement report. If I suppress duplicates, the code next to MARIA will also disappear, and since there is more than one possible code that could be there, it would create confusion.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
Suppress it using this formula

EvaluateAfter({@BuildandCheckList});
Global StringVar Array NamesList;
Global NumberVar ListSize;
Local NumberVar Index;
Local BooleanVar NameFound;
NameFound := False;

For Index := 1 to ListSize do
    If {NameField} = NamesList[Index] then
        NameFound := True;

NameFound

Open in new window


You can then suppress blank sections

mlmcc
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Author

Commented:
Where do I put that one? Sorry, I'm terrible at this.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
In the suppression formula for the object

Right click the object on the report
Click FORMAT OBJECT
Click the COMMON TAB
Click the FORMULA button to the right of suppress

mlmcc

Author

Commented:
When I put it in the Suppress formula section, the entire column was blank. When I put it in the Suppress if Duplicated formula section, it suppressed the duplicates in each group.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
Try changing the loop to go to ListSize -1

mlmcc

Author

Commented:
Ahhhhh! You're my new best friend. Thank you best friend!!!! xoxoxoxo

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial