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

Last Record of a Group

edited June 2007 in General
Delphi 7, Report Builder 9.03 Enterprise

Is there a way to know the last record in a group. I have a query that has
all the entries for transaction. On the last entry I want to print the
transaction amount. See the example below.

TranID 501
Account 1 30
Account 2 15
Account 3 10 55

TranID 502
Account 1 30
Account 3 10 40

The only way I have been able to get the information is to use the following
code:

procedure TForm1.ppDetailBand1BeforeGenerate(Sender: TObject);
var
vTranID: Integer;
begin
if not t.eof then
begin
vTranID := t.FieldByName('TranID').asInteger;

t.Next;

if vTranID <> t.FieldByName('TranID').asInteger then
ppLabel1.Visible := True
else
ppLabel1.visible := False;

if not t.eof then
t.Prior
else
ppLabel1.Visible := True;
end
else
ppLabel1.Visible := True;

ppLine1.visible := ppLabel1.Visible;
end;

Is this the best way to accomplish my goal? Are there any known problems
with moving the record position?

Comments

  • edited June 2007
    Hi Nicole,

    Manually moving the record position can be risky when generating a report.
    As a report becomes more advanced, this tends to cause problems. If,
    however you have the report working the way you would like, I would say
    stick with your method.

    Another option, for future reference, would be to place the total inside the
    group footer, then manually move the drawcommand to the proper position on
    the page (next tot he line above) when it is printed. This could be done in
    the OnDrawCommandCreate event.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.