SSRS Sub-Report Won't Load Until Refresh - sql-server

I have an SSRS 2008 report with a sub-report that takes a selected value as a parameter. For example, I have a report that takes in #ProjectID and then selects ClientID. If I pass [ClientID] as a parameter to the sub report I get an error the first time I load the report. However, subsequent loads (clicking refresh) all work fine. I do not have this problem if I pass the parameter directly to the sub-report, ie [#ProjectID].
Is SSRS passing along parameters before the select is issued so it's only working when it caches the values upon refreshing? Is there any way I can fix this without forcing all sub-reports to take in [#ProjectID]?

I figured this out. It did indeed appear to be an error with trying to populate the parameters before the query was run. I solved this by placing the sub-reports in a table which appears to delay rendering until the query has completed.

Related

How can I select all parameters to run a report, but have them run independently

My quality engineers have asked me to create a report based on a document that they fill out manually. At first glance, it appeared to be an easy enough request. It has been anything but easy. This report shows the results of two inspections and I have a parameter where the user selects one inspection or the other. As it stands now, this report runs just fine when selecting one inspection, but I am anticipating a request to be able to run the reports for both inspections at the same time. And, that's where I run into trouble.
The problem is that I have a text box in the header that is referencing a value from a table in the report that identifies the inspection. When I set the parameter to a multi-value parameter and select all, the report only displays one of the inspections across the entire report. Is it possible to have the user select both inspections but have the report run them separately? I have one dataset for the table and a column in that table that identifies the inspection. I have tried the multi-value parameter and I have tried using the filter option in the dataset properties, but I get the same result.
The easiest way to do this might be to create a new master report and use your current report as a sub-report. It's fairly simple.
Here's the basic steps...
Make a copy of your current report and rename it (say sub_InspectionReport)
Change this report so the the inspection parameter is NOT multi-valued
Create a new report and add your parameter(s) the same as you setup for your original report, This time make sure your Inspection parameter (e.g. pInspection) IS multi-valued.
Create a dataset (dsInspectionIDs) that returns a list of the selected inspection values from the pInspection parameter. The query could be something simple like
SELECT InspectionID FROM myInspectionTable WHERE InpectionID IN (#pInspection)
Note: #pInspection is the name of your report parameter, it is case sensitive.
Now add a table to the report and, as a simple, test, se the dataset of the table to your daatset dsInspectionIDs. Set the first column to show the only available field (in this example InspectionID).
Run the report and test the output using different inspection parameter selections. The table should match what you have selected...
We're almost there...
Now in one of the table cells (but not in the header) , right-click and select "Insert / Subreport". Now right-click the sub-report placeholder and set the sub report to be the copy of the original report we made at the start (sub_InspectionReport in this example). Now, still in the sub-report properties, go to the parameters tab and set the Inspection parameter to the the InspectionID field.
Now when you run the report, you will get your sub-report run once for each selected parameter value with that parameter passed to the sub-report.
Hope that makes sense, I'm not near my PC so I can't provide a sample with images at the moment.

DrillThrough in SSRS

I am creating DrillThrough Report in SSRS. This is my database.
DatabaseImage
In my SSRS first Report i just want to display the period and status. I just to show how many Files run successfully and how many failed. This is the design.First Report Design
I have written this expression to show count of success.
=COUNT(IIF(Fields!Status.Value="Success",1,NOTHING))
And For failed. I just changed the Syccess to failed. This is working fine.
This is the result of first design when i run the report.First Report Output
Now what i want. if user click on 1 which is the value of Failed column in report one. It should get me to the detail page and show all the files which where Status="Failed".
And same for success.
What i did. I change the action of Failed column value from none to "go To Report" and set the parameters. But i didn't work.
Here is the picture. Action And Parameter Image
The problem is that you are using the [Status] field value to pass to the drill down report but the way you built your first report means that this will not be available.
You have 2 ways of fixing this I think.
The quick fix:
Simply change the Status parameter value from [Status] to a static text value that your drill down report will accept, such as Failed.
The longer but possibly better way...
Change the first report to be a Matrix,
Have a row group by Period and Column group by Status. This will save you having to setup specific expressions for each column. The other advantage is that if other Status value where added to the data in the future such as 'In progress', 'Cancelled' etc... then these would automatically appear in the report.
The drill down Action would then be setup exactly as you have done now (in your screen shot) and only needs to be setup once.
Obviously it's your decision but if it was me, I would spend the time getting this done properly

Passing a parameter from main report to drillthrough SQL Server Report Builder 3.0

I am trying to restrict what users can view based on the branch that they work in. I have it working on my main report but I want to pass the branch parameter from my main report to a drillthrough subreport. How can I do this in Report Builder 3.0? Thank you.
You can pass the parameter via the url.
Example:
http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=3&ReportYear=2008
Here we're passing the report parameter ReportMonth the value 3 and ReportYear with 2008
An alternative to using a URL, you'd need the same parameters in both reports.
Go to the properties of where you want the drill-through to occur.
Go to Action
Select 'Go to Report', specify the report directory (this can be flat files or via the report server). Think this can also be a URL but I am not certain.
Select 'Add'. In the Name field, you want to put the parameter name of the parameter in the drill-through report, in the 'Value' field you want to enter the parameter of the report that you're currently in.
If you don't want the user changing this parameter, in the drill-through report, you can simply hide this parameter in the drill-through report.
This is by far the easiest way of doing what you require I believe. Hope this helps if you're still struggling.

SSRS - Passing parameter to run stored procedure

I have set up a report in SSRS which drills through to a 2nd report. The data in the second report is a stored procedure that has a parameter declared, as in:
CREATE PROCEDURE [dbo].[Procedure] (#Parameter VARCHAR(max)) AS.....
In the first report I have set up the Action on the text box properties to run the second report using the relevant parameter from the first report.
I am designing this in Visual Studio and when I 'Preview' the report in here it works correctly and the drillthrough passes through the parameter as intended. However when I deploy this onto our server and try to view the report using Internet Explorer the drill through doesn't work, I get an error saying that the parameter is read-only and cannot be modified.
From reading other posts relating to this online people have mentioned changing the parameter visibility to 'Visible' however this hasn't worked on mine.
Has anyone else experienced anything similar to this before?
Thanks.
This seems to be a common problem when passing a parameter to a subreport. Have you seen this solution? http://saiabhilash.blogspot.nl/2012/05/report-parameter-is-read-only-and.html

SSRS Subreport not seing values in only one dataset

I'm working on a series of reports which need to be shown in two languages so I've created a common header that I planned on embedding into the content of each report. I have two data sets, one that looks up a set of strings in English or French (depending on a parameter passed to the report), and another with numerical data.
The original header worked fine and when I extracted it into a separate report it also runs fine. I am just passing the name of the report to the subreport. When I run the main report, it seems that the values in my string dataset are all null (I've tried all of them) yet if I try data from my numerical dataset, the fields have values and get displayed as the title.
If I also insert a text field with the same expression to display the report title after the subreport, it works fine but the title still does not get passed to the subreport.
I cannot make any sense of why this would be happening, anyone have a clue?
I'm using Report Builder 2.0 and SQL Server 2008.
Thanks!
Alright, so I worked around this issue by simply passing my parameters on down to the subreports and letting them call the stored procs again. Not ideal since I now have to call that one stored proc 3 times but it probably won't be noticed.
I tried several other work arounds and received errors like rsAggregateInCalculatedFieldExpression, so my best guess is that this was caused by attempting to use an aggregate function (First) where it is not allowed but the error was never shown.

Resources