Recent

Author Topic: LazReport - One record per page  (Read 6053 times)

dsyrios

  • Jr. Member
  • **
  • Posts: 57
LazReport - One record per page
« on: April 14, 2017, 05:36:55 am »
Hi,
Is it possible using LazReport, to have only one record per page?
Somehow to add a "Page-break" conditionally.
Note that I use MasterData and DetailData bands.
Thanks in advance.

Laz 1.6.4/FPC 3.0.2/win32
Laz 2.0.2/FPC 3.0.4/ win10/64
Laz 2.0.0/FPC 3.0.4/ mint-mate 19.1

balazsszekely

  • Guest
Re: LazReport - One record per page
« Reply #1 on: April 14, 2017, 07:07:17 am »
Hi,

Did you try the ForceNewPage property?

dsyrios

  • Jr. Member
  • **
  • Posts: 57
Re: LazReport - One record per page
« Reply #2 on: April 14, 2017, 07:23:09 am »
Thanks GetMem,
for your attention and your patience.
But I don't know what object has the "ForceNewPage property".
Can you be a little more specific?
Laz 2.0.2/FPC 3.0.4/ win10/64
Laz 2.0.0/FPC 3.0.4/ mint-mate 19.1

balazsszekely

  • Guest
Re: LazReport - One record per page
« Reply #3 on: April 14, 2017, 07:27:36 am »
Well, I was thinking about something like this(TfrReport OnBeginBand event):
Code: Pascal  [Select][+][-]
  1. procedure TForm1.frReport1BeginBand(Band: TfrBand);
  2. begin
  3.   if Band.Typ = btDetailData then
  4.     if Band.Name = 'myDetailBand' then
  5.       Band.ForceNewPage := True;
  6. end;

dsyrios

  • Jr. Member
  • **
  • Posts: 57
Re: LazReport - One record per page
« Reply #4 on: April 14, 2017, 08:07:53 am »
Thanks GetMem,
I'll try it.
Laz 2.0.2/FPC 3.0.4/ win10/64
Laz 2.0.0/FPC 3.0.4/ mint-mate 19.1

dsyrios

  • Jr. Member
  • **
  • Posts: 57
Re: LazReport - One record per page
« Reply #5 on: April 15, 2017, 05:45:43 am »
As I saw,
the ForceNewPage property works:
1) only with  "OnBeginBand" NOT with "OnEndBand"
2) only with  "Band.Typ = btMasterData"  NOT  "Band.Typ = btDetailData"
is it right?
So I used something like that...
Code: Pascal  [Select][+][-]
  1.     procedure TForm1.frReport1BeginBand(Band: TfrBand);
  2.     begin
  3.       if (Band.Typ = btMasterData) AND
  4.          (Band.Name = 'myMasterBand')
  5.      then  Band.ForceNewPage := True;
  6.     end;
and the only problem is that the first page has only the ReportTitle.
Thanks again GetMem
Laz 2.0.2/FPC 3.0.4/ win10/64
Laz 2.0.0/FPC 3.0.4/ mint-mate 19.1

balazsszekely

  • Guest
Re: LazReport - One record per page
« Reply #6 on: April 15, 2017, 07:28:03 am »
Quote
1) only with  "OnBeginBand" NOT with "OnEndBand"
Yes, you must break the band at "OnBeginBand" event. When "OnEndBand" is fired the band is already printed, make no sense to set ForceNewPage to true, it won't have any effect.

Quote
2) only with  "Band.Typ = btMasterData"  NOT  "Band.Typ = btDetailData" is it right?
I don't know all the details of your project but if it works with btMasterData by all means use that.

Quote
And the only problem is that the first page has only the ReportTitle.
Set a global, boolean variable(FirstTime for example) to true on the following events: OnBeginDoc and OnBeforePrint, then:
Code: Pascal  [Select][+][-]
  1. //...
  2. type
  3.   TForm1 = class(TForm)
  4.  
  5.   private
  6.     FFirstTime: Boolean;
  7.   public
  8.  
  9.   end;
  10.  
  11. //...
  12.  
  13. procedure TForm1.frReport1BeforePrint(Sender: TfrReport);
  14. begin
  15.   FFirstTime := True;
  16. end;
  17.  
  18. procedure TForm1.frReport1BeginDoc;
  19. begin
  20.   FFirstTime := True;
  21. end;
  22.  
  23. procedure TForm1.frReport1BeginBand(Band: TfrBand);
  24. begin
  25.   if (Band.Typ = btMasterData) and (Band.Name = 'myMasterBand') then
  26.   begin
  27.     if FFirstTime then
  28.     begin
  29.       FFirstTime := False;
  30.       Exit;
  31.     end;
  32.     Band.ForceNewPage := True;
  33.     //put other stuff here if needed
  34.   end;
  35. end;

Quote
Thanks again GetMem
You're welcome!

PS: You should give fortes report a try. It's similar to quickreport, with much more options then lazreport.
« Last Edit: April 15, 2017, 07:42:36 am by GetMem »

 

TinyPortal © 2005-2018