Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print master-detail report for a single table

Status
Not open for further replies.

ashishh

Programmer
Jul 19, 2002
43
US
I am trying to print a report from a table which has the following columns

i_case_id
dt_date
s_detail_1
s_detail_2

I want to print i_case_id once for the case (there could be multiple rows for the same case).

The output should look like

case ID Case Date
detail1 detail2
-------------------------------------
1 Aug-5-02
Text1 Text2
Text3 Text4
2 Aug-5-02
Text5 Text6
Text7 Text8
Text9 Text10

It is a master detail sort of report except that they are coming from the same table.

Thanks for your time.
Ashish
 
Approach #1: Use a UNION statement to get the "repeating group" into a single column. Then use a report, subreport setup where the main report gives the header for each group and the subreport (multi-column) presents the details.

There's another method, but start by trying out this one.

hth,
- Ido CUT & Visual CUT: E-mailing, Exporting, Bursting, Distribution, and Scheduling of Crystal Reports:
 
Create a "detail a" and "detail b" section, insert the Case ID and Case Date in "detail a", the other two field in "detail b"

That would give the following results:

1 Aug-5-02
Text1 Text2
1 Aug-5-02
Text3 Text4
2 Aug-5-02
Text5 Text6
2 Aug-5-02
Text7 Text8
2 Aug-5-02
Text9 Text10

Then format "detail a" to be supressed if the Case_ID is the same as the previous Case_ID. You would then get:

1 Aug-5-02
Text1 Text2
Text3 Text4
2 Aug-5-02
Text5 Text6
Text7 Text8
Text9 Text10

Just what you're after.
Steve Phillips, Crystal Consultant
 
Create a "detail a" and "detail b" section, insert the Case ID and Case Date in "detail a", the other two field in "detail b"

That would give the following results:

1 Aug-5-02
Text1 Text2
1 Aug-5-02
Text3 Text4
2 Aug-5-02
Text5 Text6
2 Aug-5-02
Text7 Text8
2 Aug-5-02
Text9 Text10

Then format "detail a" to be supressed if the Case_ID is the same as the previous Case_ID. You would then get:

1 Aug-5-02
Text1 Text2
Text3 Text4
2 Aug-5-02
Text5 Text6
Text7 Text8
Text9 Text10

Just what you're after.
Steve Phillips, Crystal Consultant
 
Thanks Steve and Ido for the suggestions.

I am trying to use the conditional formatting. Please forgive my ignorance here ( I am new to CR). How do I go about suppressing detail-a when Case_ID is same as previous CaseID. I was trying to do conditional formatting using the Format Section but I do not know what the command to issue for suppressing when the following is true.

IF {I_CASE_ID} = Previous ({I_CASE_ID}) Then
Suppress.Detail-a ???

Your help is highly appreciated.

Thanks,
Ashish
 
The formula against the supress option should be just the following:
not previousIsNull({I_CASE_ID}) and {I_CASE_ID} = previous ({I_CASE_ID})

Steve Phillips, Crystal Consultant
 
Thanks Steve,

I got the report to work acceptably but the output is as follows

1 Aug-5-02
Text1 Text2
Text3 Text4
2 Aug-5-02
Text5 Text6
Text7 Text8
Text9 Text10
And I want it to be like

1 Aug-5-02 Text1 Text2
Text3 Text4
2 Aug-5-02 Text5 Text6
Text7 Text8
Text9 Text10

The underlay option would not work either because I have some additional column in detail-a which I am printing in line2. Sorry about not specifying this earlier.

Thanks for your time.
Ashish
 
Insert a group based on Case ID, place the fields Case ID, Case Date, details 1 and details 2 in the group header.

Also place the details 1 & 2 in the details section

Make sure the 'underlay following sections' is set for the Group Header (not the details section)

Set the following condition to supress the detail section (do not tick the box that says supress, simply enter this code under the X+2 button)

OnFirstRecord or previous({I_CASE_ID}) <> {I_CASE_ID}

This will cause the first detail section for each CASE ID to be supressed. I've not tested this but I'm sure it will work Steve Phillips, Crystal Consultant
 
Steve,

It WORKS! I sincerely appreciate your help in solving this problem. Thanks once again.

Ashish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top