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

Q. Making a Group Calc Dependent

edited November 2006 in General
Hi. I have something on a report that I am designing that is a bit over my
head.

What I have is 2 fields in a report group footer. 1. Is a text field say
DBText1 and the other is a calculation say DBCalc1. DBCalc1 is simply a SUM
of a field in the detail.

Here is what I want to do. If DBText1 field is blank or null, I do not want
to show the data that is in DBCalc1 on the report. If there is something in
the DBText1 field, then I do want to show DBCalc1.

I am thinking that I need to use the CALC tab and an OnPrint event for the
DBCalc1 object, but I am not sure and I am not sure of what syntax I would
use there either.

Any ideas on how to do this?
Thanks in advance,
Mike

Comments

  • edited November 2006
    Hi Mike,

    Inside the DBCalc.BeforePrint event, check the value of the field that the
    DBText component is connected to. If this field value is blank, toggle the
    visibility of the DBCalc to False. Be sure to change it back to True if the
    field has a value.

    Something like the following...

    DBCalc1.Visible := (Report.DataPipeline['MyField'] <> '');

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2006
    That worked great. However it now brings up a 2nd question.

    Ok in my senario, being that DBText1 is blank and now DBCalc1 is blank on
    the report nothing prints in that Group Footer for several groups.

    What this does however is that it leaves a blank space for the group footer
    and basically looks stupid when you generate the report.

    So is there a way then to dynamically change the group footer height to 0 if
    nothing prints? Since everything else is keying off of the value in
    DBText1, it would be ok to key off of that for this too.

    Thanks Again,
    Mike

  • edited November 2006
    Hi Mike,

    One option would be to set your group footer band to have a phDynamic print
    height. Then place a stretchable Region inside the band and move the
    DBText components inside the region. Now, inside the
    GroupFooter.BeforePrint event, toggle the visibility of both the DBText and
    DBCalc components. If they are both not visible, the band should shrink to
    0.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2006
    Excellent that worked well.

    Thanks.
This discussion has been closed.