Search code examples
reporting-servicesssrs-2008

SSRS '08 Object reference not set to an instance of an object


Full error from Preview window in Visual Studio '08 (BIDS): "An error occurred during local report processing. Object reference not set to an instance of an object."

There are no further errors/warnings detailed in the Error List or Output windows.

Background: On this report I am using a table to display a sub-report [x] number of times, dependant on the number of related objects that exist in the SQL database. That is to say that the sub-report is set within one of the cells (the only cell) of the table, in a row that repeats for each item returned in a dataset.

Removing the sub-report allows the master report to compile and run, so I feel the issue is related to the arrangement of the sub-report. If the sub-report only displays once, then the master report compiles and runs fine, it is only when a second instance is required that the issue arises.

When testing the sub-report separately, it compiles and runs when given the parameters for each instance it is being asked to render from the master report. So I can rule out the idea that the data for the second instance is causing it to fail (in some div-by-0 type way).

Given the lack of detail from the error and that the sub-report works on it's own, I do not understand why this is happening.

Does anyone have any ideas for debugging or suggested solutions?

Thanks

Brian

tldr: Master report fails when a sub-report repeats more than once.


Solution

  • I figured out a solution. The sub-report is being passed 4 parameters, one of these had a value referring to the value a table-cell on the master report. Changing this parameter to be the value of the expression that was setting that table-cell fixed the issue. I have no idea why this is a solution, but it is.

    In more detail: [table_cell_a] had an expression computing it's value. [parameter_a] for the sub report was set as "=ReportItems("[table_cell_a]").Value", when I changed the expression for [parameter_a] to mirror the expression for [table_cell_a], everything worked again.

    This is messed up, and I can't even begin to understand why it behaves like this. If [table_cell_a] was not being computed before the calls were made to the sub-reports, I could understand. But if that was the case, how come the report worked when there was only one sub-report?

    If anyone can provide an explanation, I would be most grateful.

    Brian