In my report group section at the bottom of my report, totals are calculated. Some calculations are dividing based on the Sum() of fields shown in the detail section.
If the textbox is defined with value at design time as follows:
=IIF(Sum(Fields.NumberOfReceipts1) = 0,
0,
Sum(Fields.Sales1) / IIF(Sum(Fields.NumberOfReceipts1) = 0, 1, Sum(Fields.NumberOfReceipts1))
)
This works fine and there is no error. However, because of the number of total boxes in the report - I ended up getting a Stack Overflow message just on entering the component.Initilializer() (First { bracket). So decided to create these boxes at runtime:
textBox.Value = "=IIf(Sum(Fields.NumberOfReceipts1) = 0, 1, Sum(Fields.NumberOfReceipts1))";
But this now causes the following error:
"An error has occurred while processing TextBox 'rtNoSales12': An error has occurred while executing function IIf(). Check InnerException for further information. ------------- InnerException ------------- Exception has been thrown by the target of an invocation. ------------- InnerException ------------- Index (zero based) must be greater than or equal to zero and less than the size of the argument list."
How can I avoid the Divide by 0 error by defining report textbox values at runtime?