I posted this question to Stack Overflow and haven't had a bite, so I thought I might try here:
I have a report I'm building in SSRS. I have text box that makes use of custom code at the bottom of the report (not in the footer). This is the function in use:=Code.WinnerTextBox(First(Fields!WinnerName.Value, "FightDetails" ),First(Fields!Blue_Corner.Value, "Judge1"),First(Fields!Red_Corner.Value,"Judge1"),First(Fields!FightDecisionCode.Value, "FightDetails" ),First(Fields!DecisionTypeName.Value, "FightDetails" ),First(Fields!FightDecisionRoundNo.Value, "FightDetails" ), First(Fields!FightDecisionTime.Value,"FightDetails" ),First(Fields!SubmissionTypeName.Value, "FightDetails" ))Here is the custom code in use:
Public Class CalculateTotals Dim public redTotal AS Integer Dim public redRoundTotal AS Integer Dim public blueTotal AS Integer Dim public blueRoundTotal AS Integer Public Function AddRedTotal(ByVal RedCornerDeduction AS Integer, ByVal RedCornerPoints AS Integer) AS Integer redRoundTotal = RedCornerPoints - RedCornerDeduction redTotal = redTotal + redRoundTotal return redRoundTotal End Function Public Function GetFinalRed() return redTotal End Function Public Function AddBlueTotal(ByVal BlueCornerDeduction AS Integer, ByVal BlueCornerPoints AS Integer) AS Integer blueRoundTotal = blueCornerPoints - blueCornerDeduction blueTotal = blueTotal + blueRoundTotal return blueRoundTotal End Function Public Function GetFinalBlue() return blueTotal End Function Public Function GetLeaderName(ByVal RedName AS String, ByVal BlueName AS String) AS String IF GetFinalBlue() > GetFinalRed() Then return BlueName ElseIf GetFinalRed() > GetFinalBlue() Then return RedName ElseIf GetFinalRed() = GetFinalBlue() Then return "Draw" Else return "Something is very wrong with the data" End If End Function End Class Dim Public Judge1 AS CalculateTotals = New CalculateTotals() Dim Public Judge2 AS CalculateTotals = New CalculateTotals() Dim Public Judge3 AS CalculateTotals = New CalculateTotals() Dim Public red AS Integer Dim Public blue AS Integer Dim Public leader AS String Public Function GetRed() AS Integer red = Judge1.GetFinalRed() + Judge2.GetFinalRed() + Judge3.GetFinalRed() return red End Function Public Function GetBlue() AS Integer blue = Judge1.GetFinalBlue()+Judge2.GetFinalBlue()+Judge3.GetFinalBlue() return blue End Function Public Function WinnerTextBox(ByVal Winner As String, ByVal BlueCorner As String, ByVal RedCorner As String, ByVal DecisionCode As Integer, ByVal DecisionType As String, ByVal DecisionRound As Integer, ByVal FightDecisionTime As String, ByVal SubmissionType As String) As String Dim ReturnString As String If (GetBlue() = GetRed()) Or (DecisionCode = 10) Or (DecisionCode = 11) Or (DecisionCode = 12) Then ReturnString = "Draw: " & CStr(GetBlue()) & "-" & CStr(GetRed()) & " (" & DecisionType & ")" ElseIf (Winner Is Nothing) Then If (GetBlue() > GetRed()) Then ReturnString = "Leader: " & BlueCorner & CStr(GetBlue()) & "-" & CStr(GetRed()) Else ReturnString = "Leader: " & RedCorner & CStr(GetRed()) & "-" & CStr(GetBlue()) End If ElseIf (DecisionCode = 1) Then ReturnString = "Winner: " & Winner & " By " & DecisionType & " In Round " & CStr(DecisionRound) & " At " & FightDecisionTime ElseIf (DecisionCode = 9) Then ReturnString = "Winner: " & Winner & " By " & DecisionType & " " & SubmissionType & " In Round " & CStr(DecisionRound) & " At " & FightDecisionTime ElseIf Winner = BlueCorner Then ReturnString = "Winner (" & CStr(GetBlue()) & "-" & CStr(GetRed()) & "): " & Winner & " By " & DecisionType & " In Round " & CStr(DecisionRound) & " At " & FightDecisionTime ElseIf Winner = RedCorner Then ReturnString = "Winner (" & CStr(GetRed()) & "-" & CStr(GetBlue()) & "): " & Winner & " By " & DecisionType & " In Round " & CStr(DecisionRound) & " At " & FightDecisionTime End If Return ReturnStringNow when the report is run, it renders absolutely correct on the screen, however when it is exported to PDF or printed, the textbox renders the following text:
Draw: 0-0 (KNOCKOUT)
This leads me to believe that the process of printing my report is causing the custom code to somehow try to run again, and has no data and therefore returns this. Is there a way to prevent that from occurring? Is that what is happening? And if so, can you help me understand why it is re-rendering when printing? Also, any suggestions on how to make this print properly?