Print Empty rows if dataset is empty
Hi
I have the situation where I need to print a band even if there are no rows for the dataset, and it must always print the band at a specific height (well the height of 3 records).
Report Layout: (actually subreport, but shouldn't make a difference I think)
Header Band (must ALWAYS be printed)
MasterData band (must ALWAYS be printed - dataset returns only 3 or less rows if there IS data, if there is no data or less than 3 rows then the band must print to the height of 3 rows)
Footer band (must ALWAYS be printed)
Any suggestions?
TIA
Regan
I have the situation where I need to print a band even if there are no rows for the dataset, and it must always print the band at a specific height (well the height of 3 records).
Report Layout: (actually subreport, but shouldn't make a difference I think)
Header Band (must ALWAYS be printed)
MasterData band (must ALWAYS be printed - dataset returns only 3 or less rows if there IS data, if there is no data or less than 3 rows then the band must print to the height of 3 rows)
Footer band (must ALWAYS be printed)
Any suggestions?
TIA
Regan
Comments
You may want to look at other psots on child fillers if you desire to reserve or fill up the empty space in your report
Be sure you have print on first and last page checked for your header and footer
Hope that helps
something like:
The rowcount set to anything other than 0 means you are forcing it to be printed X number of times, regardless of the dataset (even if it doesn't have one).
The Header and Footer should behave as you expect with this.
I hope it helps
Well, in that case...
(It's getting a little dodgy at this point, if this doesn't work, try another way)
if your bands and record spacing is always the same height(not stretching )
instead of using framesof memos add an overlay band and use lines.
tip on overlays they are realy underlays, set the designer page to large height in design mode
add your overlay band below all others after designing
Thanks for the suggestions. I found this forum topic which gave me my final solution [topic="5791"]Repeating the MasterData for n-times[/topic].
Below is my final code. I would be keen to know, if there is a better way of doing this.
var
bPrintedLastTop3International : Boolean;
bPrintedLastTop3National : Boolean;
dsTop3National: TfrxDataSet;
dsTop3International: TfrxDataSet;
...
procedure MasterData21OnBeforePrint(Sender: TfrxComponent);
begin
if (Engine.FinalPass) then
if (dsTop3National.RecordCount>0)
and (dsTop3National.recno <= dsTop3National.recordcount)
and (not bPrintedLastTop3National) then
begin
if (dsTop3National.recno = dsTop3National.recordcount) then
bPrintedLastTop3National := True;
Memo24.Text := dsTop3National.Value;
dsTop3National.Next;
end
else
Memo24.Text := '';
end;
procedure MasterData22OnBeforePrint(Sender: TfrxComponent);
begin
if (Engine.FinalPass) then
if (dsTop3International.RecordCount>0)
and (dsTop3International.recno <= dsTop3International.recordcount)
and (not bPrintedLastTop3International) then
begin
if (dsTop3National.recno = dsTop3National.recordcount) then
bPrintedLastTop3International := True;
Memo27.Text := dsTop3International.Value;
dsTop3International.Next;
end
else
Memo27.Text := '';
end;
//Main script begin ... end
begin
dsTop3National := Report.GetDataset('fdtsHL_Top3National');
dsTop3International := Report.GetDataset('fdtsHL_Top3International');
if (Engine.FinalPass) then
begin
dsTop3National.First;
dsTop3International.First;
bPrintedLastTop3International := False;
bPrintedLastTop3National := False;
end;
end.
Regards,
Regan
Sorry, forget to add the RowCount property of the MasterBands were set to 3.
Regan