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

Blank When Zero on calc field

edited June 2004 in General
Hi,

i'm trying to put a calc field.visible to false if value = 0. but the
calculation is done on the second pass.

it's hard to describe so here is the code.

PROCEDURE DetailAfterGenerate
var
tempJanv : integer;

begin
{ i get totals for each month }
if report.firstpass then
begin
tempJanv := totaljanv;
end
else {I fill values of the fields percentage of each mission
tempon... is calculated in subreport }
begin
PCJanvssmiss.value := temponJanv / tempJanv * 100;

{ Blank when 0 }
if temponJanv = 0 then
PCJanvssmiss.Visible := false
else
PCJanvssmiss.Visible := true;


end;

end;

The probleme is that when i print preview, some values apear and some
other don't. and when i print it on paper, some other values
disappears.

i tried to put the { Blank when 0 } bloc in other events and it
didn't solve the problem.

I hope i have described my problem correctly, and that someone can
help me.

thanks in advance.

Comments

  • edited June 2004
    why can't you use the "blank when 0 flag " in designer?
    "Emmanuel Claus" ha scritto nel messaggio
  • edited June 2004
    It's possible to use it on DBCalc Fields but not on Calc Fields.


    On Tue, 29 Jun 2004 12:45:33 +0200, "Ernest"
  • edited June 2004
    Hi Emmanuel,

    The problem with using an event like the DetailBand.AfterGenerate is that
    there is no guarentee that it will only fire once. If you are trying to set
    the visibility of a component inside an event other than the
    TppVariable.OnCalc event, you will need to do some custom checking whether
    the event has been fired for that value or not already. Also, if you are
    checking the value of a dbfield perhaps, you may want to use the
    DetailBand.BeforePrint instead of the AfterGenerate.

    --
    Thanks for supporting ReportBuilder! Please vote for ReportBuilder in the
    Delphi Informant Readers Choice awards!

    http://www.delphizine.com/ballot2004/

    Best Regards,

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