title: Reporting Services - How to get sum of values using reportitems!textbox1.value
body: <p>I am using custom code to get the sum of values using reportitems!textbox1.value because I know I cannot use it without custom code because of the error 'Aggregate functions can be used only on report items contained in page headers and footers'. I am using a table inside a list with the list group 'list1_Details_Group'. I am succeeding in getting the sum with the following code but it is not giving the sum per 'list1_Details_Group'. 
  What I want is to have the total of the values per the 'list1_Details_Group'
  My code is:</p>
  
  <pre><code> Public sum_of_crew As Integer = 0 
      Public Function SumUp(ByVal value As Integer) As Integer
      sum_of_crew = sum_of_crew + value 
      Return sum_of_crew 
      End Function
  </code></pre>
  
  <p>I am calling this function from a textbox inside my table detail row with the expression which accumulates the value:</p>
  
  <pre><code>=Code.SumUp(ReportItems!textbox134.Value)
  </code></pre>
  
  <p>I then have another textbox inside the list outside the table with the following expression which shows the sum:</p>
  
  <pre><code>=Code.sum_of_crew
  </code></pre>
  
  <p>This textbox which is supposed to show the accumulated sum as per the last value in the table detail row is giving the correct sum but only for the first of the group values as the second of the group values are including the value of the first of the group values. The value does not start at 0 again after the value of the first of the group values.
  Please help!</p>