Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 3.63 KB

File metadata and controls

58 lines (44 loc) · 3.63 KB
title Add code to a paginated report
description Find out how to call your own custom code for any expression you have in your paginated report in Report Builder.
ms.date 09/25/2024
ms.service reporting-services
ms.subservice report-design
ms.topic how-to
ms.custom
updatefrequency5
helpviewer_keywords
code [Reporting Services]
custom code [Reporting Services]
expressions [Reporting Services], code
adding code
reports [Reporting Services], code

Add code to a paginated report (Report Builder)

[!INCLUDEssrs-appliesto] [!INCLUDE ssrs-appliesto-ssrs-rb] [!INCLUDE ssrs-appliesto-pbi-rb] [!INCLUDE ssrb-applies-to-ssdt-yes]

In any expression, you can call your own custom code in a paginated report. You can provide code in the following two ways:

Add embedded code to a report

  1. In Design view, right-click the design surface outside the border of the report and select Report Properties.

  2. Select Code.

  3. In Custom code, enter the code. Errors in the code produce warnings when the report runs. The following example creates a custom function named ChangeWord that replaces the word Bike with Bicycle.

    Public Function ChangeWord(ByVal s As String) As String  
       Dim strBuilder As New System.Text.StringBuilder(s)  
       If s.Contains("Bike") Then  
          strBuilder.Replace("Bike", "Bicycle")  
          Return strBuilder.ToString()  
          Else : Return s  
       End If  
    End Function  
    
  4. The following example shows how to pass a dataset field named Category to this function in an expression:

    =Code.ChangeWord(Fields!Category.Value)  
    

    If you add this expression to a table cell that displays category values, whenever the word Bike is in the dataset field for that row, the table cell value displays the word Bicycle instead.

Related content