Question
“How do I detect the last detail printed in a group?”
Solution
Create a separate dataset that counts the values present for each group based on the grouping field. You can then use this information to determine when the detail band has reached its final record for that group and you can make alterations to that band’s components as needed.
Download: LastDetailInGroup.zip
Sample Delphi code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
procedure TForm1.ppDetailBand1BeforeGenerate(Sender: TObject); begin FDetailCount := FDetailCount + 1; end; procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject); var liDetailCount: Integer; begin liDetailCount := daBDEQueryDataView2.DataPipelines[0]['COUNT(*)']; //Hide the line if it is the last detail in the group. ppLine1.Visible := liDetailCount <> FDetailCount + 1; end; procedure TForm1.ppGroup1AfterGroupBreak(Sender: TObject); begin FDetailCount := 0; //After each group move to the next record in the group detail count dataset. daBDEQueryDataView2.DataPipelines[0].Next; end; |