Page 1 of 1

How to deal with DataCount=0?

Posted: Thu Aug 16, 2012 1:46 pm
by Jennypi
Hi all,

In one of my reports, I would like to show as many labels as the number contained in the field "number".
For example, if for row 1 "number" contains 2, 2 labels are printed.
For row 2, "number" contains 0, no labels are printed.
For row 3, "number" contains 5, 5 labels are printed.
It works very well with 2 DataBands (one master DB + one with mastercomponent= the first one) and this BeforePrint event:

Code: Select all

if (plantation.nb_of_fruits==0)
{
DataBand2.CountData=0;
plantation.Next();
DataBand2.CountData=1;
}
else
{DataBand2.CountData=plantation.nb_of_fruits;}
But I have a problem when 2 successive rows have 0 in "number". The first one is ok (no label), but DataCount for the second one is set to 1 because of the code in the event.
How can I do?

Thank you.

Re: How to deal with DataCount=0?

Posted: Thu Aug 16, 2012 2:04 pm
by HighAley
Hello.

Try to use next code:

Code: Select all

DataBand2.Enabled = true;
if (plantation.nb_of_fruits==0)
{
    DataBand2.Enabled = false;
} else {
    DataBand2.CountData=plantation.nb_of_fruits;
}
Please, look at the attached report template.

Thank you.

Re: How to deal with DataCount=0?

Posted: Thu Aug 16, 2012 2:35 pm
by Jennypi
Perfect, thanks a lot.

Re: How to deal with DataCount=0?

Posted: Fri Aug 17, 2012 3:19 am
by Andrew
Hello,

We are glad to help you.

Thank you.