SSRS Object reference not set to an instance of an object - reporting-services

I'm working on a complex SSRS report that contains a number of subreport, with a total of five levels of nested sub-reports. This is a lot, but necessary due to the complicated nature of the top level report.
I've encountered an odd error with the last subreport I've added:
Warning 1 [rsErrorExecutingSubreport] An error occurred while executing the subreport 'ThingRateQuotaWrapper' (Instance: T0R0S0S1T0R0x0S0): Object reference not set to an instance of an object. C:\Users\mmxxxxxxx\Documents\Visual Studio 2012\ThingsReporting\ThingsReporting\Thing 2014 Consolidated Report.rdl 0 0
The problem here is that when I run the second level report (one of the reports contained in the top level "consolidated" report), everything works fine. But in the top level report, I get this unepected error.
The specific subreport mentioned is four levels down from the top report, so I would expected the second level report to fail if there was an issue, however as just mentioned that works perfectly.
In addition, the RDL and line number mentioned in the error message tells me nothing useful.
I've tried everything I can think of to solve this problem, including deleting, saving, re-inserting and configuring all the subreports from the ThingRateQuotaWrapper upwards. At this point I can think of nothing else to try that makes any sense.
How can a report fail because of a sub report four levels down, when other reports in between work correctly?
Anyone got any ideas or tips? I'm using SQL Server 2012 Business Intelligence and Visual Studio Premium 2012.

I've solved this problem, however I don't entirely understand the solution so I welcome any comments which might expand on it.
My approach was to look through each expression in the set of reports and subreports that make up my consolidated report, looking for any that might fail for any reason. I discovered that the visibility expression for the tablix row which contains the ThingRateQuotaWrapper subreport had the dreaded red squiggly line beneath it.
I believe the cause of the field warning is that the visibility expressed used a dataset other than the primary dataset of the tablix. I reworked the tablix dataset to contain the required column to determine visibility of the subreport, then updated the visibility expression to use the new column in the primary dataset. This fixed the problem.

This issue still impact SSRS in Visual Studio 2017 when renaming a sub-report.
Delete all the object in the \bin\ folder and VS will rebuild it without the error.

In my case, sub report's name had been changed (params and everything were correct) just name had been changed. Lead to this error.

This tends to happen when you change the names on reports. I accomplished this by deleting the .data files in my project directory as this stores the cached data of your reports. Then restart visual studios and the problem should be resolved.
In short:
Delete .DATA files in directory
Restart Visual Studios
Hope this helps.
Thanks
Gavin

To anyone coming to this old thread, I had the exact same error message with the following configuration:
Main report (top parent level report) calls 5 sub report hierarchy deep
The sub report is crashing only when generating from the Main report. Everything is fine when calling from each sub report level (all!) including the sub report itself
Pre-requisite explanation
The business wants me to show either a Bar chart OR a textbox on a dedicated condition.
To avoid empty spaces produced by a ReportItem (my subReport outputing a bar chart) that is hidden, I usually put them inside a Tablix and manage the Row visibility. Like that, no empty spaces is generated !
Old structure causing issue
I have one tablix with two rows :
The first one contains my sub report outputting a bar chart
The second one contains a simple TextBox
The tablix's dataset is a dataset containing the Textbox's text value (and that's the key of the problem !)
New structure fixing the issue
I have now 2 tablix :
One tablix with a dummy dataset ("SELECT 1 as 'Dummy') associated to the tablix. This tablix calls the bar chart's sub report
A second tablix with the same dataset as before (containing the Textbox's text value)
UPDATE 29.06.2022
The solution described above worked without RowVisibility condition. As soon as I've added my expression it fails again :
=IIF(RowNumber("myDataSetName")=0, True, False)
Solution: replace by this condition instead :
=IIF(Count(Fields!MyFieldName.Value) = 0, True, False)
This produces the same : When there the SQL query returns no row, I want to hide it.
It's very strange that SSRS doesn't tell my expression is wrong somehow, and last but not least, it's very weird that the expression works in all report levels except from the Main report. Either an expression is wrong or not.
Looks like a bug in SSRS (SQL Server 2017...maybe it's fixed in SQL Server 2019)

Related

SSRS Subreport disappears after page is changed

I'm using Visual Studio 2019 with SSDT(SQL Server Data Tools) and "Microsoft Reporting Services Projects" to create a SSRS Report. In this Report I have several Subreports to show detail information.
It can happen that one of the subreports shows no additional data. In this case I still want the structure of the Subreport to be shown, like this (table structure with thinner Bordes is the Subreport):
But when I switch to another page and back to this page of the Report, the structure is gone:
This seems to be the case, when there is no information in the Subreport.
There are no visibility properties set, neither in the Subreport nor in the "parent"-Report, so everything should be visible all the time.
Yes it will happen because your sub report does not return anything and hence the blank.
For Testing just try running one of your sub report only (without main report) with parameter which does not return data and you will see your sub report page is completely empty
Now how to solve this issue:
For your sub report:
I would add static table (without datasets) and add it on top of your tablix.
I will add visibility rule to this static table to show only when your datasets does not return data. so that this static is visible only when original subreport data is not available, else you have your subreport data been shown.
This happend because SSRS think should hide the subreport since all the dataset are empty (or the only one you have) so to avoid that in your subreport just add a new dataset with
'select 1 as one'
that will do the job

SSRS - Report item not linked to a DataSet

I an having an issue in SSRS.
I am using SSDT 2015.
Step 1:
I am using reporting services project.
Created a Report
Added a Data Source
Added a Data Set
Step 2:
I'm adding a parameter/Expression, but if I go to available value and try to add a data set field it is showing me: "Report item not linked to a dataset."
I was working with SSRS previously for 20 days and it didn't happen.
For anyone still experiencing this problem, if you click on the rectangle (the white background, not any of the elements on top of this), and you should see the grey borders appear. If you then right-click on the top-left of the grey borders, and select 'Tablix Properties', you can then link your tablix to your dataset, by changing the 'Dataset name' drop down to the name of your dataset.
You either need to set the parameter to get values from a query, or you can use an aggregate function (e.g. first()) to get the first value from a dataset that the item is not linked to. That would be:
=first(Fields!ActorID.Value, "dtsActor")
Also, yay WiseOwl.

CSV Datasource in Subreport

I'm new to JasperReports and I have a big problem inserting Subreports from CSV. I've been looking for information for 3 days and can not understand what must I do.
I have a dataset named RB1 in csv format, that I need to import to JasperReports. In the main report I have no problems, I can import it and show fields as I want.
The problem arises when I need to insert a subreport with the same database.
I create another report named SUB_1, and link it to the database RB1 as if it was an usual report, and I put the variable COLUMN_0 to be shown in the details section. I previsualize it and it is OK.
I go back to the main report and drag the item SUBREPORT to the summary section and select "select an existing report". I choose the report SUB_1 -> NEXT
I select "use same JDBC connection used to fill the master report" -> NEXT
In the Dataset Parameters I clic ADD and write:
PARAMETER NAME: COLUMN_0
PARAMETER EXPRESSION: $F{COLUMN_0}
What I'm trying to do is to link the variable COLUMN_0 of the main report with the variable COLUMN_0 in the subreport.
Now, when I try to previsualize the report, the subreport does not show.
In the Properties of the Subreport I have:
EXPRESSION: "SUB_1"
PARAMETERS MAP EXPRESSION:
CONNECTION EXPRESSION: $P{REPORT_CONNECTION}
DATA SOURCE EXPRESSION:
What am I doing wrong? I guess that many things, but could not find any answer online with this in detail in a way that I can understand it.
I solved the first part of my problem: I could print data in the subreports from the main report. Or better said, I could half-print some data.
I use an answer to the question I posted, to continue asking about this problem.
I have been thinking and looking for info and I think that the problem now could be because of the indices. The point is that when my subreport is used, there is some data that has been used by the main report, so the subreport seems not to work for the lines that were used by the main report. Is that possible?
If this is the problem, is there any way to make my subreports to work for all data and not just for the ones that are not used in the main report?
Thank you very much!!
I think I am really close to solve it thank to you :D:D

SSRS Pull Variables Or Values From Sub Report Into Main Report

I have a main report with several sub reports, each of these with slightly different queries and different ways to show the data.
So, in my situation, I have a textbox that needs to compile data from a few different reports with varying criteria. E.G.
MainReportTextbox =(Sum(columnA, "Main Dataset"))-(SubReportTextBox))
OR
MainReportTextbox =(Sum(columnA, "Main Dataset"))-(subReportVariable))
I saw a few suggested solutions, such as this. Which uses the =[Reports]!MainReport!SubReport!Textbox scheme. The problem is that [Reports] is not a recognized identifier.
I did consider to scrap sub reports and just have everything run on the same main report, but we lose the functionality of being able to use the reports individually, without maintaining the same thing in two places.
So I guess my question is, can you pull variables or element(particularly textboxes in a table) values from sub reports?
If the answer is simply no, please show me some information about why it is no or how it is no from MSDN or a valid source and give some valid counter suggestions.
The links in the question and comments sometimes refer to non-SSRS reports: the syntax [subreport].[Report]![MyFieldName] or [Reports]![YourReportName]![YourSubReportName]![TheValueFromTheSubReportYouWantToReference] are not used in SSRS. It is, however, used in designing MS Access reports, as ojeffrey points out in the discussion you link to.
There is no common method to access data in a subreport. The SSRS model is that parent report data is processed, subreport data is processed, the subreports are rendered, results go back to the parent, then parent is rendered, including the subreport as appropriate. The only data passed between the two is parameters are passed into the the subreport, and rendered output is passed back to the parent. You'll see the that data passed in from the parent must be as report parameters here: http://technet.microsoft.com/en-us/library/ms160348(v=sql.100).aspx
All parameters that are required by the subreport must be included in
the Parameters list. If a required parameter is missing, the subreport
is not displayed correctly in the main report.
For citing authoritative sources:
This discussion sums it up:
No, referring to a report item in a subreport is not allowed.
But that is a bit old, there is also this more recent discussion of work-arounds, provided by Microsoft employee and a MS BI MVP:
You are going to need to replace the subreport item with a data region
like list, table, or matrix to be able to get the proper reference you
are looking for.
[Skipping down to another post]...
Now, it seems you want to calculate the
difference between main report and the subreport. Also, because they
have the different data source, so you cannot use nest
table/matrix/list, right? If so, one workaround I can think of is
pass parameter to the sub report and calculate the total/subtotal in
sub report. I mean, create several hidden/ internal parameters, pass
the values from main report to sub report through parameters and then
calculate the total/subtotal there.
Jeroen's answer to the linked question point towards the direction I would go: use a "Shared Dataset" and enable caching if the dataset is slow to execute. The same dataset execution can then be used for the parent and subreports. This can change the use of parameters: they usually get moved from the SQL query to the filter of the Dataset in the report.
But with the Lookup function introduced in SSRS 2008R2, you can get very flexible with report level joins between datasets.
The details of how I'd design this depend a lot on how much other data needs to get passed back and forth, and how neatly the queries for the reports can be knit together.
Create variable in main report and update it in sub report so you can get value back to main report
ex:
Create formula in main report with name {#Total} place flowing in it
WhilePrintingRecords;
shared Numbervar myTotal := 0;
NOTE : placing ; will not print value and without ; will print value in above example value will not be printed if you want to print value of formula just remove ; from second line ex
WhilePrintingRecords;
shared Numbervar myTotal := 0
now place {#Total} in report header of your main report
now create second formula in sub report where you want to add subtotal to main report formula with name {#addTotal} place following lines in it
WhilePrintingRecords;
shared Numbervar myTotal;
myTotal := myTotal + 200; //or any formula or field
add this formula to place in sub report where you want to add value to total
now create formula in main report to show grand total with name {#showTotal} and place following lines in it
WhilePrintingRecords;
shared Numbervar myTotal;
myTotal
place {#showTotal} in your main report where you want to show this value in report but remember one thing you should place this formula after sub-report.
NOTE : to assign value to variable use := operator

Passing Parameters In SSRS

I have 5 reports, which I need to render on seperate pages of an Excel Workbook, so I have created a Master report and intend to call them as subreports. This works perfectly, but the problem is that I need to control the name of each worksheet, and I believe that the trick here is to use a rectangle, and set the PageName property to the desired name of the worksheet.
The issue is, that as soon as I place the subreports inside a rectangle and add a Page Break or a PageName, when I run the master report, I get an error saying One or more parameters were not specified for subreport _____
The same thing happens if I put the sub report inside a list.
How do I either pass the parameters in via a rectangle, or name the worksheets without the use of a rectangle?
I am using SSRS 2008R2
I have got to the bottom of this, and it appears to be the most bizarre SSRS bug. Once you move the subreport inside a list or rectangle and add a Page Break, SSRS flips the date format of the date parameters, and hence you end up passing in values that SSRS does not recognise as dates.
Even more obscure, If you pass flip the date values so that the report succeeds, the next time you run it, SSRS flips them back the other way, and then then they stay flipped that way until you exit the report.
Go back into the report and repeat the steps above once more. I will raise this on Microsoft Connect.