2012-11-05 3 views
0

에 코드 값을 반환합니다.어떻게 내 보고서에서 아래의 경우이 변수

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")))) 

하지만 거짓 상태에서 내가 녹화에 대한 오류를 생산에 0을 regetting의 값을 얻을 consiquently 내가 얻기 위해 code.SumLookup을 회수하고 이후/찌르다.

시간에 code.sumlookup을 호출하여 값을 변수에 저장하면 값을 확인해야 할 때마다 호출 할 필요가 없습니다.

또는 다른 해결책이 있으면 알려주십시오.

+0

귀하의 질문에 소개, 상호 작용 및 일반적인 흐름이 부족합니다. 질문을 검토하고 편집하여 조금 더 편하고 (그리고 더 즐거운) 읽을 수 있었습니까? – Jeroen

답변

0

보고서에 텍스트 상자를 추가하고 프로덕션 식에 값을 설정하려고했습니다. "Production"이라는 텍스트 상자의 이름을 지정하고 ReportItems! Production.Value 구문을 사용하여이 값을 참조하지만 동일한 오류가 발생합니다.

내가 찾은 해결책은 다음과 같습니다 : 아래의 함수의

, 보고서 작성기 기능의 모든 부분을 평가합니다. 즉, 함수에 "prod = 0 인 경우"가 고려 되더라도 여전히 Rec/Prod 평가를 수행하므로 오류가 발생합니다. 이 수식을 시도해보십시오. 추가 'IF'는 함수가 오류없이 평가되도록합니다.

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)/IIF(code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))=0,1, code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2")))) 
0

보고서에 텍스트 상자를 추가하고 프로덕션 식에 값을 설정하려고합니다. "생산"텍스트 상자의 이름을 지정한 경우 ReportItems! Production.Value 구문을 사용하여 해당 값을 참조 할 수 있습니다.

관련 문제