Forum Discussion

Maaaaaaaax's avatar
Maaaaaaaax
New Member
2 years ago
Solved

error: [BC30451] - paginated report

error: [BC30451] "Code" is not declared. - thats my error code in the paginated report. How can i declare the variable? I have to copy the paginated reports from the old software to the new one. It worked so far at the old software from Microsoft.

Thanks for help.

The variable called Code.

1 Reply

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, Maaaaaaaax 

     

    The error BC30451 means that you are trying to use a variable or a class that is not declared or not accessible in your code. To fix this, you need to make sure that you have declared the variable or the class with the correct scope and visibility, and that you have imported the necessary namespaces or assemblies.

     

    One possible cause of this error is that you are using a custom code block in your report definition, and you have not declared the Code variable. The Code variable is a special variable that represents the custom code block, and it must be declared as Public Shared in the report properties. For example:

     

    Public Shared Function GetTotal (ByVal value As Decimal) As Decimal Return value * 1.1 End Function

     

    To declare the Code variable, open the Report Properties dialog box, click References, and add the following line in the Declarations section:

     

    Public Shared Code As Object

     

    This will allow you to use the Code variable in your expressions, such as =Code.GetTotal (Fields!Sales.Value).

     

    For more information on how to use custom code in paginated reports, please refer to this article.

    Report and group variables collections references in a paginated report - Microsoft Report Builder & Power BI Report Builder | Microsoft Learn

    Custom code and assembly references in expressions in a paginated report in Report Designer - Microsoft Report Builder & Power BI Report Builder | Microsoft Learn

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.