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

detail item numbers

edited August 2011 in General
Hello

I want to simply number the individual line items in a report that has a
group header and each group starts on a new page. With QuickReports there
is a system variable called qrsDetailNo that will provide a detail number
unique to each detail item. In RBuilder, I can use a ppLabel and set the
text to a counter variable that I increment in the
ppDetailBandBeforeGenerate event as long as I only proceed from first to
last record without scrolling backwards. See code at bottom.

The only way that I have determined to assign an item number that will
remain with the specific detail line item when scrolling backwards is to: a)
create persistent fields in the SQLQuery component, b) create a new
"presistent" integer field to hold the item number, c) after executing the
SQL start at the first record and populate the correct value into the item
number field and d) use the calcualted persistent "item number" field to
display the item numbers in RBuilder.

The solution posed in paragraph #2 appears overcomplicated and requires
persistent fields which, in general, I prefer to avoid because of
refactoring concerns. Is there a simpler solution?

TIA

John

var tempItemNumber: Integer;


procedure TDataModuleRBuilderReports.ppLabel41GetText(Sender: TObject;
var Text: string);
begin
Text := IntToStr(tempItemNumber);
end;

procedure TDataModuleRBuilderReports.ppDetailBand4BeforeGenerate(
Sender: TObject);
begin
if tempStatus <> adsQueryBalByOffice.FieldByName('Status').AsString
then
begin
tempStatus := adsQueryBalByOffice.FieldByName('Status').AsString;
ppPageBreak1.Visible := True;
tempStartNewPage := True;
end
else
begin
if tempStartNewPage = False then
begin
ppPageBreak1.Visible := False;
if tempCurrentPageNumber = ppReportBalByOffice.PageNo then
begin
tempItemNumber := tempItemNumber + 1;
end;
end;
end;

end;

procedure TDataModuleRBuilderReports.ppReportBalByOfficeStartPage(
Sender: TObject);
begin
if tempCurrentPageNumber < ppReportBalByOffice.PageNo then
begin
tempCurrentPageNumber := ppReportBalByOffice.PageNo;
end;
end;

Comments

  • edited August 2011
    Hi John,

    An easier way to do this would be to place a DBCalc component inside the
    detail band and set its calculation type to dcCount.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2011
    Nico

    That is exactly what I needed. Once again, thanks for your knowledge.

    John

This discussion has been closed.