Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Print only last record for a given group - how?

edited July 2001 in General
I need to give the end user the following functionality - for a give key
(Field1;Field2;Field3) the only records which I want to be printed should be
these with the maximum value of Field3 for every value of Field1;Field2.

So for records:

1;1;1
1;1;2
1;1;3

2;2;4
2;2;8

2;3;5

I need to print only:

1;1;3
2;2;8
2;3;5

The end user should be able to create such reports himself.
Does the end-user solution in RB gives such a possibility?

Thank you
Janusz

Comments

  • edited August 2001
    First, I would probably try to build a SQL statement dynamically to do this
    for the enduser behind the scenes, such that the data being read by the
    report is already in sorted by distinct field2 values and also returns the
    max value of field3 for all field2 values.

    You should be able to create a count of records by group as a lookup. Then
    use that to set the visibility of the detailband to false until the last
    record of the group is going to print. Use the BeforePrint event of the
    detailband. You can't use a dbCalc to get a group count, short of creating a
    twopass report and storing the value in a TList and using the second pass to
    turn off the detail bands until the last record of a group is about to
    print.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.