Search code examples
crystal-reports

Crystal Reports - Get First, Second and Third occurrence of linkedTable value


I have the following One-To-Many scenario:

One Record -> To -> Many Notes (of types X, Y and Z)

In the page for each Record, I need to include only the first 3 Notes of Type X in chronological order.

How do I do this? I've tried setting 3 subreports, but I can't tell the second and third subreport which notes have already been selected as part of the prior occurrences.


Solution

  • Just an extension to your solution.

    1. First select only select 3 records to be retrieved from database.

    2. Now sort either ascending or descending order in all 3 sub reports.

    3. Now in sub report 1 suppress 2 and 3 records in the same way in second sub report suppress 1 and 3 records and in sub report 3 suppress 1 and 2 records.

    You can suppress the records by placing the special field Record Number and suppress condition would be

    if recordnumber = 1
    then true
    else false
    

    Same way for second and third records.