Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Way to not print a varialbe based on its value.

edited November 2005 in General
Rb7 and Delphi7

I need a way to stop a line from printing based on the value of a variable.
Examp:
if the value of variable1 is >=3 then do not print that line.
if the value of varialbe1 is <3 then print the line.

I tried setting visible to false but this leaves a blank line.

--
Have a great day!

Walt Kersten
Wkersten@wkersoft.com

Comments

  • edited November 2005
    Hi Walt,

    You will need to write code to reset the line's visibility back to True if
    the variable is less than three. If I were designing this report, I would
    place a TppRegion inside the Detail band with its ParentWidth and
    ParentHeight set to True. Then place all my data aware components and
    others inside the region. That way I can toggle the visibility of the
    entire band with one line of code. For instance...

    procedure TForm1.DetailBandBeforePrint(Sender: TObject);
    begin
    if ppVariable1.Value >= 3 then
    ppRegion1.Visible := False
    else
    ppRegion1.Visible := True;
    end;

    You will also need to be sure the variable has been calculated before this
    event fires. Trace your code to be sure.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    I have done this and just the values that I want print.
    The problem is that for each value that does not print it leaves a blank
    line.
    2.5
    2.0

    2.5


    2.9
    There are several thousand items that it goes thru and hopefully there will
    only be 15 or 20 that should print....
    to have a blank line for each one that does not meet the criteria won't
    work.

    Procedure DetailBeforePrint
    var x,y,i : integer;

    s : string;

    z : double;

    begin

    i:=1;

    y:=0;

    x:=0;

    region1.visible:=true;

    repeat

    s:=inttostr(i);

    if SportsMan['Score'+s]>0.0 then

    begin

    y:=y+SportsMan['Score'+s];

    x:=x+1;

    end;

    i:=i+1;

    until i > 25;

    if x>0 then

    z:=y/x

    else z := 0.0;

    if (z>0.0) and (z<=3.0) then

    Variable1.value:=z

    else

    region1.visible:=false;

    end;


    Have a great day!

    Walt Kersten


    wkersten@wkersoft.com
  • edited November 2005
    Hi Walt,

    Try setting the TppRegion's Stretch property to True and that the
    DetailBand.PrintHeight is set to phDynamic. This should remove the space
    that it is taking up when the region's visible property is set to false.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.