SSRS Sub-Report not displaying in production - reporting-services

Some days I just really hate M$.
I have an SSRS Report, the dataset is being populated by a stored procedure. Report display the results one district (grouped rows) per page. Stored procedure is returning aggregated counts. So far so good.
I've added two sub reports to the tablix, one in the left column, one in the right. Almost exactly the same. I've clicked on the cell, clicked insert, and selected SUB-REPORT. Then I click on the new SUB-REPORT, and use the drop down to specify which report to use as a sub-report.
They too have a data set being fed by a stored procedure, which may return from 0 to several rows. Both sub-reports use exactly the same parameters, with the same names.
---------------------------------------------------
|___________________DISTRICT 12___________________|
|_____________Item 1|__75|____________Item 2 |__42|
|_____________Item 3|__15|____________Item 4 |__45|
|_____________Item 5|___5|____________Item 6 |__16|
|_____________Item 7|__65|____________Item 8 |___0|
|_____________Item 9|__12|___________Item 10 |__55|
|=================================================|
|______Sub Report 1______|______Sub Report 2______|
|_________category 1|__27|_________category A|__16|
|_________category 2|__15|_________category B|__42|
|_________category 3|___2|_________category C|__60|
|_________category 4|___6| |
|_________category 5|__16| |
---------------------------------------------------
It looks and works fine in Visual Studio. Each sub report works fine on it's own, and works fine within the main report as well. But when I deploy all 3 reports, sub report 1 says "Error: Subreport could not be shown."
Sub-reports take exactly the same parameters. Sub reports get district ID, year, etc to pull data.
I've recreated the offending sub-report with another name, replaced it in the main report, with the same result.
I've recreated the main report, giving it both sub-reports, with the exact same result, sub-report 1 and sub-report 1b dos not work, sub-report 2 does.
I compared the sub report files with each other using ExamDiff (shameless plug, excellent tool!) and found no real differences.
I cracked open the main report file with XML Notepad (another useful tool) and found no real differences in the way they are set up.
All reports are stored in the same directory.
I opened the project file, and found nothing of interest there.
I even added the external tool to clear local report cache as suggested elsewhere.
I am stumped. I am certain this has been encountered before. Any pointers?
As always, thank you to my compatriots on Stack Overflow. Best source of advice for developers on the planet.

This could be the old FMTONLY and SSRS problem.
For more details please see these links
http://www.sqlservercentral.com/articles/Reporting+Services+(SSRS)/119024/
No fields for dynamic SQL stored procedure in SSRS with SET FMTONLY
I use this in some of my old SSRS stored procedures when the resultsets do not get displayed initially
CREATE PROCEDURE report1 AS
BEGIN
DECLARE #FMTONLY BIT;
IF 1 = 0
BEGIN
SET #FMTONLY = 1;
SET FMTONLY OFF;
END
-- Stored proc main code here
IF #FMTONLY = 1
BEGIN
SET FMTONLY ON;
END
END -- End of stored proc / RETURN

Seriously, sometimes I hate M$.
The stored procedures for the two sub reports only bring back 4 fields, one I don't even use (district ID). The report only has three text boxes in a table, one is just a literal. The other two are
=Description + " (" + code + ")"
and
=DistCounts
ABSOLUTELY NOTHING TO THESE.
Finally we took the one that worked, copied the XML to an new sub report, changed the dataset, field names and literal, redeployed, and it works. Comparing the one that works with the 2 that didn't ... shows nothing of interest. Arrrrgh!
As I said, both used the same input parameters, the stored procedures were just counting different fields. Wasted more than a day on a wild goose chase, and we still don't know what was wrong.

Related

SSRS Parameter using a stored procedure with a parameter

I have a SSRS report that pulls data using a stored procedure. Two of the parameters on this report have default values stored (i.e. Role:Student, ID:Guest)
One of the parameters is a dropdown that is filled with a different stored procedure using the two parameters mentioned above. When I set the parameters for this new dataset to #Role and #ID, I get a rsInvalidReportParameterDependancy error. I have changed the order of the two parameters with no success. Any thoughts on how to resolve this?
It sounds like you have three parameters but you have only mentioned changing the order of two. In my head, I would think that Role and ID must come first in your list of Parameters. I'd start by sorting those to the top. Then you should be able to add in your third parameter, populated by the result of those two. Can you provide any more information of what you've tried or what doesn't work?
The answer to this question has been posted before. However, I did not realize that I had the same issue. The answer has to do with the parameters not being in the correct order. For instance, I had 6 parameters on the main report. Parameters 5 and 6 were hidden to the user. Parameter 3 contained a dropdown that was populated by a stored procedure that needed #Param5 and 6. Even though parameters 5 and 6 had default values, it would not work until I moved param5 and 6 before param3.
I changed the order of the parameters on the report's main stored procedure and then change the parameters order in the report. (I ended up doing this using a text editor.)
#param1
#param2
#param3
#param4
#param5
#param6

SSRS Object reference not set to an instance of an object

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)

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

Hiding Sub report in SSRS (and not executing the Stored Procedure) [duplicate]

This question already has answers here:
Hiding Sub report in SSRS based on Parameter (and not executing the Stored Procedure)
(3 answers)
Closed 8 years ago.
I can set the hidden property using an expression which will hide/show the sub-report, but what I found using SQL Profiler, is that the sub-report stored procedure is still executed, even if the sub-report is hidden.
Is anybody aware of a way to avoid this, other than changing the stored procedure itself. If not, does anybody know the reason why the stored procedure is executed even thought the sub-report is hidden?
This is same question as This one but no answer there so i am asking again any help will be great
I have a large complex report (up to 10k controlling rows) where there are 1:n rows in 7 subreports. This runs like a dog unless you can suppress the SQL execution in the subreports (since most of the subreports are hidden most of the time).
After much pain, I have found that it is really easy to suppress the subreport rendering and dataset execution. All you need is a required report parameter in the subreport. There is usually an ID field passed to a subreport, so this should be no problem.
In the main report, the parameter is passed by an expression similar to:
=Iif(Fields!SubReportXisHidden.Value,Nothing,Fields!ID.Value)
The subreport will barf on the missing parameter, will not render and will not execute the SQL.
Deep joy!
Just do that logic in SQL Management Studio. SSRS is not an event driven system really and you can do some small things in code blocks and with Visual Basic but not much. It is not meant to program execution plan level coding on complex if then else scenarios for doing at run time execution plans. In fact it gets mad if you try to do advanced looping and indexes as that is meant for the server more than this add on. It is meant to present your data you give to it and some very basic conditioning of elements. If you really want to either do a query and the cost of it or not just add a bit flip to a proc created in SQL Management Studio like:
create procedure dbo.ToCreateOrNotToCreate
(
#input varchar(32)
, #Run bit
)
as
BEGIN
if #Run = 1
Select 'You selected to run "' + #input + '" at a cost!'
else
Select 'Don''t run and save performance'
END
exec dbo.ToCreateOrNotToCreate #input = 'My Input', #Run = 1
exec dbo.ToCreateOrNotToCreate #input = 'My Input', #Run = 0

Access report prints multiple pages when text box control source is using a multi-value field from a table

The Access 2010 report i have has a text box that uses a multi-value field from a table for its control source. I know multi-value fields in tables are bad but its what i have to work with at the moment.
The problem i am having is that even though its only a two page report when i physically print it or do a print preview i get more then 2 pages. So if the multi-value field has (2) values i will get (4) pages total with the same information basically (2) copies.
How can i prevent the report from printing a copy for each value?
Ok so I will answer my own question now that i have found a work around.
I found a work around that will let me print only the pages i want (ie the first two pages or one copy not several)
In my macro instead of using RunMenuCommand PrintObject that just prints the report.
I created a vba function
Function cmdPrint()
DoCmd.PrintOut acPages, 1, 2 //acPages, start_page, end_page
End Function
and used this function from the macro using RunCode cmdPrint()
Now I only get one copy not several. Like I said its a work around but it works for me and i hope that it will help someone else someday with the same problem.