Reputation: 276
I am troubleshooting an RDLC file created by a third party. They've got some VB.NET code in the report, and an expression in the detail row is calling a function defined by the code. The function doesn't return any data; it just populates an array. There's nothing else in the detail row, and the row itself is hidden.
In the footer of a summary group, there are two more expressions that call functions which use the array populated by the first function. If the detail row is visible, those functions work fine. If the detail row is hidden, the expressions return #Error. It doesn't appear to be calling the function, and the array is staying empty.
I modified the detail row to be as small as possible, but there are quite a few rows being returned, so I'm getting quite a bit of white space. Is there a way to hide the detail row and still have it call the function from the report code?
I found the following question which seemed to be what I was after, but I don't think the respondents understood the question.
Hide a row in RDLC report without disabling the code execution
I'm using Visual Studio 2013. I appreciate any suggestions. Thanks.
EDIT:
Here's the report Code section, if it helps clarify the situation.
public dim TranDate(0) as DateTime
public dim CashFlow(0) as Double
public dim BFCashFlow(0) as Double
public dim RowCount as Int32=0
Public Function PrepairCashFlowArray(byval myTrandate as Date,ByVal myCashFlow as Double,ByVal myBFCashFlow as Double)
Redim Preserve TranDate(RowCount)
Redim Preserve CashFlow(RowCount)
Redim Preserve BFCashFlow(RowCount)
TranDate(RowCount)=myTrandate
CashFlow(RowCount)=myCashFlow
BFCashFlow(RowCount)=myBFCashFlow
RowCount =RowCount +1
End Function
Public Function GetNETIRR() as Double
Return ((IRR(CashFlow, -0.1)+1)^4-1) * 100
End Function
Public Function GetGROSSIRR() as Double
Return ((IRR(BFCashFlow, -0.1)+1)^4-1) * 100
End Function
Here's the detail row expression.
=code.PrepairCashFlowArray(Fields!perfdate.Value,Fields!cashflow.Value,Fields!bfcashflow.Value)
Here's one of the two summary row expressions (they're similar).
="Net of Fee IRR: ="&format(code.GetNETIRR(),"##,#0.#0")
Upvotes: 0
Views: 855
Reputation: 11
There is no clean solution for this problem because not evaluating or not executing expressions or code in hidden objects is a feature since 2008 version. Back in the days of SSRS and reportviewer 2005 you could put execution of code in hidden object and the evaluation or execution of that would normally happen, but then they decided to change it.
It's a hack, but you can make another function which would have same parameters as PrepairCashFlowArray and maybe one more parameter which you would use for toggling Hidden property if you need it. So you could do something like:
Function HidProp(byval myTrandate as Date,ByVal myCashFlow as Double,ByVal myBFCashFlow as Double, byval hide as Boolean)
If hide Then ...call PrepareCashFlowArray with same parameters...
Return hide
End Function
So you can set Hidden property on details row to Code.HidProp(all_params, hide:True). I haven't seen that you said that there is some conditional by which you set hidden property on details row, but this extra parameter gives you the opportunity to not call your function if you want to leave calls to function in details row, or you can delete the call from details and call HidProp always from hidden property, then you can call your function without if-then-else.
This way you can force report to evaluate code for every detail row.
I found one answer about this on MS connect, so maybe these clues can help you also: https://connect.microsoft.com/SQLServer/feedback/details/354787/reporting-services-rc0-hidden-code-not-executing
Upvotes: 1