我的报告中有以下案例:
应收款:RunningValue(Fields!Receivable.Value,SUM,Nothing)
生产:code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))
Rec/Prod:应收/生产。
Public Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()
suma = 0
ct = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
ct += 1
Next
If (ct = 0) Then return 0 else return suma
End Function
问题在于 Rec/Prod,如果 prod = 0 我收到错误。
我试图提出以下条件:
IIF(code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))=0,0,RunningValue(Fields!Receivable.Value,SUM,Nothing)/(code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))))
但是因为在错误的情况下,我正在调用 code.SumLookup 以获得重新获取 0 的值以用于生产,因此我得到了 Rec/Prod 的错误。
我如何才能按时调用 code.sumlookup 并将其值保存到变量中,这样我就不需要在每次需要检查值时调用它。
或者如果有任何其他解决方案,请告知。