Discussion:
SubDetail band not printing correctly in QuickReport
(too old to reply)
Diego
2006-03-21 19:00:02 UTC
Permalink
I have a report with a Detail band and a SubDetail band. The Detail Band is
connected to a DataSet.

On the BeforePrint event of the Detail band I get some values from the
database, then on the BeforePrint event of the SubDetail band I create a
query using those values. This query returns me some records and I want to
print each of them on as a separated DetailBand.

My code looks like this:

procedure Tform1.QRSubDetail1BeforePrint(Sender: TQRCustomBand);
begin
Qry.Sql.Add := 'Select * From Invoice where Value >= ' + IntToStr(FValue)
;
Qry.Open;

while not Qry.Eof do
begin
// QrLabel1 is on the SubDetail Band
QrLabel1.Text := Qry.FieldByName('Customer name').AsString;
Qry.Next;
end;
end;

The DataSet property of the SubDetail Band is connected to Qry.

The problem is that with this code, a band is printed for each record, but
all those bands only displays the data from the last record of the query.

How could I print the SubDetail bands properly, each band with the data from
the correct record?

I'm using Delphi 7 and QuickReport 3.6.2.

TIA,
Diago Abib
Darren
2006-03-24 15:45:36 UTC
Permalink
The SubDetail band will iterate through the records of its dataset the same
way the Detail band does with it's.
You do not need to navigate through the dataset manually.
Post by Diego
I have a report with a Detail band and a SubDetail band. The Detail Band is
connected to a DataSet.
On the BeforePrint event of the Detail band I get some values from the
database, then on the BeforePrint event of the SubDetail band I create a
query using those values. This query returns me some records and I want to
print each of them on as a separated DetailBand.
procedure Tform1.QRSubDetail1BeforePrint(Sender: TQRCustomBand);
begin
Qry.Sql.Add := 'Select * From Invoice where Value >= ' + IntToStr(FValue)
;
Qry.Open;
while not Qry.Eof do
begin
// QrLabel1 is on the SubDetail Band
QrLabel1.Text := Qry.FieldByName('Customer name').AsString;
Qry.Next;
end;
end;
The DataSet property of the SubDetail Band is connected to Qry.
The problem is that with this code, a band is printed for each record, but
all those bands only displays the data from the last record of the query.
How could I print the SubDetail bands properly, each band with the data
from the correct record?
I'm using Delphi 7 and QuickReport 3.6.2.
TIA,
Diago Abib
Loading...