Passing Parameters In SSRS - reporting-services

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.

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

Setting ShowParameterPrompts property when returning from a drill through report

In SSRS 2012, I have a Main Report that takes 1 parameter, a dropdown. I have a drill through report that is displayed from a Main Report. When the user is viewing the drill through report, I added a link on the drill through report that goes back to the main report. I use the same parameter value so that the main report is displayed before the drill through report was selected.
The main report displays correctly, but the paremeter area is hidden when the user comes back from the drill through.
I read that there is a ShowParameterPrompts property but I cannot find where to set it.
Is there anyway to set this property from the subreport so the parameter area is showing?
UPDATE
In the Action tab, make sure you select the Go to report option. If you specify the report this way rather than a URL, SSRS will use the appropriate report viewer controls.
You should see something like ...RSViewerPage.aspx?rv:RelativeReportUrl=... in your URL after you click on a drill-through.
The settigs should look like this:
EDIT:
Since this isn't working, let's try the URL method instead. Try this in a browser first to get the URL right and then specify it in the reports. To add the parameter in the URL after ".rdl" add "&rp%3a", then the name of the parameter, "=", and the value. So in your case:
= Globals!ReportFolder & "/SurveyResults.rdl&rp%3aSurveyName=" & <expr>
Of course the expression at the end there would be the value for the parameter. If your survey names have spaces, you'll need to URL encode them by replacing the spaces with "+" or "%20".

How do I get an RDLC report to run report custom code?

I have an RDLC report in VS 2013 that has two distinct sections. I'd like to show a footer only in the first section. To do this, I have a report variable called IsFirstSection that is set to "True". In my footer I have an if statement that displays text if this variable = "True".
Before the second section is displayed on the report I would like to set this variable to false. To do this, I have a function in the report custom code called SetVariableValue that takes a variable and a value and does just that. I have a text box before the second section that calls this function with Code.SetVariableValue(Variables!IsFirstSection, "False"). However, this code doesn't seem to be executing as IsFirstSection is still "True".
When I do this exact set up in an RDL report it works correctly. I even tried making a custom code function in the RDLC that just returns a string and when I call it from a text box expression nothing is displayed. How can I get the RDLC to run report custom code?
A Report Variable seems a poor choice for this requirement. It's probably just chance that it appears to work under some conditions. Some quotes from the doco:
"By default, a report variable is calculated once ..."
"You cannot control when the report processor initializes a variable or evaluates an expression that updates a variable."
https://msdn.microsoft.com/en-us/dd255208.aspx
I would use a ReportItems reference instead. This would likely point at a textbox which presents field that changes value between "sections".

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