Recent

Author Topic: Lazreport: Band only to print when a field has a certain value  (Read 5617 times)

MoellerCLaus

  • Full Member
  • ***
  • Posts: 107
    • Vig Foreningsprogram
I have generated one sqllite datase with all the fields and data that is needed in a report.
However I want to display different band layouts dependant on the value in one of the fields.

If there a way to have 3 masterbands where they only print on a certain conditions?

Any hints highly appriciated.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 986
Re: Lazreport: Band only to print when a field has a certain value
« Reply #1 on: June 20, 2021, 11:26:43 am »
hello,
have a look to this

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

MoellerCLaus

  • Full Member
  • ***
  • Posts: 107
    • Vig Foreningsprogram
Re: Lazreport: Band only to print when a field has a certain value
« Reply #2 on: June 20, 2021, 01:14:00 pm »
Thanks for the hint Jurassic.
Maybe it shows a possible way through - I now got introduced to script.
The reports I need here are more advanced then displaying a table. I just make a deep-dive into LazReport.

Soner

  • Full Member
  • ***
  • Posts: 240
Re: Lazreport: Band only to print when a field has a certain value
« Reply #3 on: June 20, 2021, 02:09:48 pm »
Use the event TFrReport.OnBeginDoc i.e:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.frReport1BeginBand(Band: TfrBand);
  2. begin
  3.   if (Band.Name='MyBand1')and(DBFieldValue=1) then  Band.Visible:=true
  4.   else if (Band.Name='MyBand1')and(DBFieldValue<>1) then  Band.Visible:=false
  5.   else if (Band.Name='MyBand2')and(DBFieldValue=2) then  Band.Visible:=true
  6.   else if (Band.Name='MyBand2')and(DBFieldValue<>2) then  Band.Visible:=false
  7.   else ....
  8.  
  9. end;
  10.  
  11.  
« Last Edit: June 20, 2021, 02:14:32 pm by Soner »

MoellerCLaus

  • Full Member
  • ***
  • Posts: 107
    • Vig Foreningsprogram
Re: Lazreport: Band only to print when a field has a certain value
« Reply #4 on: June 20, 2021, 02:51:19 pm »
Hi Sonar

I will try too - the suggestion from Jurassic works fine but a lot of script has to be made. Further scripts does not work with rectangles, lines etc..

 With your tip I suppose I could have several master-bands and swich them on and of..

Thanks  8-)

MoellerCLaus

  • Full Member
  • ***
  • Posts: 107
    • Vig Foreningsprogram
Re: Lazreport: Band only to print when a field has a certain value
« Reply #5 on: June 20, 2021, 03:58:13 pm »
Hi Sonar

I defined 2 bands as master in the report-designer.
Wrote the below handler.

It does not work  :(

Code: Pascal  [Select][+][-]
  1. procedure TSuperPrintForm.frReport1BeginBand(Band: TfrBand);
  2. begin
  3.   Case TypeRapport of
  4.     5: Begin // Schedule
  5.       If (aUdskriv_source.DataSet.FieldByName('schedule_pause').AsString = '') and
  6.         (Band.Name = 'MasterDataEvent') Then Band.Visible := True
  7.       Else If (aUdskriv_source.DataSet.FieldByName('schedule_pause').AsString = '') and
  8.         (Band.Name = 'MasterDataPause') Then Band.Visible := False
  9.       Else If (aUdskriv_source.DataSet.FieldByName('schedule_pause').AsString = 'P') and
  10.         (Band.Name = 'MasterDataEvent') Then Band.Visible := False
  11.       Else If (aUdskriv_source.DataSet.FieldByName('schedule_pause').AsString = 'P') and
  12.         (Band.Name = 'MasterDataPause') Then Band.Visible := True
  13.       Else If (aUdskriv_source.DataSet.FieldByName('schedule_pause').AsString = 'M') and
  14.         (Band.Name = 'MasterDataEvent') Then Band.Visible := False
  15.       Else If (aUdskriv_source.DataSet.FieldByName('schedule_pause').AsString = 'M') and
  16.         (Band.Name = 'MasterDataPause') Then Band.Visible := False;
  17.     end;
  18.   end;
  19. end;
  20.  

Soner

  • Full Member
  • ***
  • Posts: 240
Re: Lazreport: Band only to print when a field has a certain value
« Reply #6 on: June 20, 2021, 04:41:07 pm »
It is working on my example.

Maybe I didn't understand your question.

Look my example.

MoellerCLaus

  • Full Member
  • ***
  • Posts: 107
    • Vig Foreningsprogram
Re: Lazreport: Band only to print when a field has a certain value
« Reply #7 on: June 20, 2021, 05:12:45 pm »
Hi Sonar

Thanks so much for your effort in helping and your example.
Yes I am afraid you misunderstood me.

I want the report to one format with a box when a value is X and another format of the band when value is Y.
Your example  shows all of data on one format of band first and then the same on format second.

What I want to achieve is:
Record 1 Format 1 due to value = x
Record 2 Format 1 value x
Record 3 Format 2 value y
Record 4 Format 1 value x

 ::) Thanks I will try to find a way.


dseligo

  • Sr. Member
  • ****
  • Posts: 314
Re: Lazreport: Band only to print when a field has a certain value
« Reply #8 on: June 20, 2021, 05:54:46 pm »
You didn't say you want to change format.

You could do it in script, something like this:
Code: Pascal  [Select][+][-]
  1.   FontStyle:=[[FontStyle]];
  2.   FontSize:=[[FontSize]];
  3.   Visible:=[v6];
  4.   Adjust:=[a6];
  5.  

This is from one of my programs. I then use OnGetValue event to set this values.

MoellerCLaus

  • Full Member
  • ***
  • Posts: 107
    • Vig Foreningsprogram
Re: Lazreport: Band only to print when a field has a certain value
« Reply #9 on: June 20, 2021, 07:55:07 pm »
Hi dseligo

Yeah Maybe I was unprise - sorry for that.
No I was hoping for to be able to change the format of the band. Rectangles, colors, lines, images etc. A completely different band.

Still looking for it.

Soner

  • Full Member
  • ***
  • Posts: 240
Re: Lazreport: Band only to print when a field has a certain value
« Reply #10 on: June 20, 2021, 09:06:37 pm »
Your example  shows all of data on one format of band first and then the same on format second.
No they aren't same, they are different bands.Only I didn't change the color, font or other properties from second band but you can do it.
I thought you want switch between bands but when you want change color, font or other properties than use TfrReport.OnEnterRect event. It is same approach.

MoellerCLaus

  • Full Member
  • ***
  • Posts: 107
    • Vig Foreningsprogram
Re: Lazreport: Band only to print when a field has a certain value
« Reply #11 on: June 21, 2021, 04:10:48 pm »
Hi Soner

Ok I see I will try out.

In the old Delphi days the reportingtool was QuickReport with Quick Design. In Quick-designer you could have multiple masterbands and in the dialogbox for masterband was an option called print if. There you could have a function, variable= something etc.
Please se attached.


 

TinyPortal © 2005-2018