1 (edited by dbk 2018-11-16 15:29:59)

Topic: [SOLVED] Conditional statements used on the report itself

Hello friends,

I have checked the forum for a solution but i didn't seem to find one.

I'm thinking of a way to have a conditional statement in the report, i will give an example:

Let's say i have a table: parents and a table: kids. On my report, the parents details with kids should be displayed on the top of the page, if the parents do not have kids their details should be displayed on the bottom of the page.

So basically i would like a script that shows a report label (data) on a certain part of the report if a condition is met, if it is not met then show the same report label on a different location in the report.

Is there a way to do this?

Thanks in advance!

Kind regards

2 (edited by dbk 2018-11-15 21:18:57)

Re: [SOLVED] Conditional statements used on the report itself

Hello friends,

So i think i am getting close.

Let's say i have this code in the report designer, and lets say table field haskids is a TEXT value, i want to match it exactly with the text value 'YES':

 var
       haskids: String;
       nokids: String;  

begin
       if <Report1."haskids"> = 'Yes' THEN      
       haskids:= <Report1."name">                            
end.

If this could work i then i could just enter [haskids] variable in a text label in the report where it should show up, if there are no kids then the variable has no value so nothing would show.

So basically i want to match the TEXT value of table field haskids with TEXT value 'Yes'.

Any ideas?

Re: [SOLVED] Conditional statements used on the report itself

I made an example for you

Post's attachments

Attachment icon Phone Book report.zip 46.87 kb, 439 downloads since 2018-11-16 

Dmitry.

Re: [SOLVED] Conditional statements used on the report itself

Hello Dmitry,

Thank you very much for the example. I am trying to understand it.

Could you tell me how to compare the following to a TEXT value instead of an Integer?

<Report."person.calc_qtynumbers"> = 0;

Should it be like the following?

<Report."person.calc_qtynumbers"> = 'textvalue';

I notice your example uses the masterdata etc but i think for my purpose it would be much more flexible to use variables that i can inside a text label.

Re: [SOLVED] Conditional statements used on the report itself

I fixed it for now, i am comparing it to the id which is an integer instead against the text value that is entered in the table. This works for now but if something in the future would change (value of id) it would break.

Re: [SOLVED] Conditional statements used on the report itself

another way:

if <Report."person.calc_qtynumbers"> = 'sometext'  then GroupHeader1.Visible := True else GroupHeader1.Visible := False;
Dmitry.

Re: [SOLVED] Conditional statements used on the report itself

DriveSoft wrote:

another way:

if <Report."person.calc_qtynumbers"> = 'sometext'  then GroupHeader1.Visible := True else GroupHeader1.Visible := False;

thank you Dmitry!