jack.li
jack.li

Reputation: 973

Crystal report pass last row data in each group to parent report

I have some question about crystal report pass value from sub report to parent report.

Now I have a sub report group by userID.Now I want to Pass last row Data each UserID . forexample sub report like this:

UserID : Jack
           id     No    Time     Diff
           1      1    08:10       0
           1      2    08:20      10
           1      3    08:35      15
Last Row:  1      4    09:10      35 

UserID : Peter
           id     No    Time      Diff
           2      1     08:10       0
           2      2     08:40      30
           2      3     08:45       5
           2      4     08:55      10
Last row:  2      5     09:00       5    

Parent report need like this:

  UserID    No    Time     Diff
   Jack     4     09:10     35       (show last row for jack  in sub report)
   peter    5     09:00      5       (show last row for Peter in sub report)

How to pass last row for each user to parent ? How can I archive this function?

Upvotes: 1

Views: 1299

Answers (1)

I realize this is an old question, but hopefully this will still be of use to you.

Since you are returning multiple values to the main report, and the number of total rows is undefined, it may be easier to do the following:

  • Create a second subreport that is a copy of the first subreport
  • In the detail section of the new subreport, add the following code to the Suppression formula for the detail section: Next ({YourTable.id}) = {YourTable.id}

Basically, the formula will suppress the detail record if the next record's id is the same as the current id. This way, only the last record for each id will be shown.

You can format the detail line in the second subreport to appear how you want.

The only downside to this is that the subreport will essentially run twice, so if it's a slow report, your report just got slower.

Upvotes: 1

Related Questions