passing values into Sub-Reports SSRS - sql-server

I have a master report that has no parameters. But I have to include a sub-report with the same grouping as the master report. (i.e, the same report has to show data for the same project listed in the master report) I'm using different Datasets for both reports but the tables come from the same database. I've tried including a parameter into the subreport and pass the current projectID into the parameter of the subreport. It doesn't seem to be possible.
Is it possible to pass field values in master report as parameters in subreports?

I'm a bit curious on your "it doesn't seem to be possible" because I'm currently working on master report and subreport as well. The answer for your short question is "YES". it is absolutely possible to pass value from master report to subreport.
So Can you please check them again whether their properties are correct or not?
For example.
Your subreport's parameters are created properly?
You can try put your subreport inside detail row of your master report.
When you set properties of subreport, you can set which field of master report you want to be a parameter for subreport. it's quite straightforward.
Hope this help.
PS. sorry for my poor english.

Absolutely yes.
Put a dataset in your main report that will go through your projects as you want it. Then put a LIST, that's the key point. The list should refer to this dataset.
Now put your dataset inside the list's container area and set it's parameter to the project ID of your main report's dataset.
Easy.

This is just clarification of what the previous people said:
NOTE: In this example T9_PK is the primary key for Table 9 (i.e. the employee table)
The purpose here is to create a subreport that is the 'Time Card' for each employee, and then create a Main report that has all the employee Time Cards, each on a new page.
Create a report that uses a parameter (e.g. Parm: T9_PK) {This will be the Sub-report e.g. TimeCard.rdl}
Drag drop 'List' control onto design surface of a new report {This will be the Main Report}
Add a dataset to the Main Report that has a field that will end up being the Parameter of the 'Sub-report.
Drag the field (e.g. T9_PK) from a dataset {previously added to report}into the List 'Control.
Drag drop a Subreport control into the Cell of the List Control, on the Main Report (e.g. AllTimeCards.rdl).
Set the subreport to the previously created report (e.g. TimeCard.rdl, with a single Parm: T9_FK)
Set the Subreport properties => Parameters:
Name: T9_PK
Value: [T9_PK]
NOTE: the Parameter for this sub-report is the one that is coming from the dataset for the Main report
Right click on '(Details)' in the 'Row Groups' Pane (below Design Surface) => New Group => T9_PK
As an additional option set the page breaks:
Right click on '(T9_PK)' in the 'Row Groups' Pane (below Design Surface) => Group Properties {window}
=> Page Breaks {left pane} =>
Page Break Options:
[x] Between each instance of a group

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.

SSRS Report Builder Sub-Report Sorting

I have an SSRS report that contains 20 sub reports in it. Each sub-report represents a phase in a specific cycle. All sub-reports are identical in formatting and such, containing specific data to that phase and displaying a start and end date. I was wondering if there is a way in Report Builder to essentially have those sub-reports be dynamic and sort themselves based on their specific start dates instead of just displaying them the one I have them listed in my report?
This is quite simple.
You already have you main report and sub reports so that's good. I assume your subreport takes a parameter which indicates the phase.
Assuming this, let's say the parameter your sub-report accepts is called pPhase
In your main report, remove all the existing sub reports
Next, create a dataset, lets call it dsLoop
Set dsLoops dataset query to return the phases in order for example SELECT DISTINCT PhaseNumber from myTable ORDER BY PhaseNumber
Now add a table control, remove the header row and two of the columns leaving just a single cell.
Make this cell as wide as you need, wide enough for your subreport, height does not matter.
Set the DataSetName property of the table to dsLoop
In the remaining cell, right-click and choose Insert --> Subreport. A subreport control will fill the cell.
Right-Click the subreport control and choose Subreport Properties, choose your subreport from the list
Still in the subreport properties, click the parameters tab, add a new parameter.
Set the Name to the parameter name that your subreport accepts (pPhase in our
example) . Finally, set the Value to the name of the field that contains
your parameter data (PhaseNumber in our example)
That's it...
Now when you main report runs, a row will be created in your table for each entry in dsLoop, each row will contain your subreport and each will have the parameter passed to it that is specific to each row.
If you have any issues, let me know and I'll post a full example.

SQL Server Report Builder for Shipping Labels, One per page

I am trying to replace our outdated shipping label program with a SQL Server report, and I am very green when it comes to doing this. I am testing using an ODBC connection with some sample data. I have created a DataSource which is a simple "SELECT * FROM LABELLIST" statement. Each row in this table contains ONE label.
In the DataSet I have each column that is needed (To, From, Carrier, PO, etc) listed. I have dragged the fields onto a blank report and in the expression it is set to "=Fields!FROMADDRESS.Value". As mentioned earlier, each ROW is a new label, but when previewing, I only get the first record as a label. What do I have to use (tablix, matrix, list, grouping?) to accomplish this and how?. I'm not sure how to search for this answer online and was hoping to get a reference page to read on how to do it. Everything I've found pertaining to labels or "row to page mapping" is showing how to print multiple labels/rows to one page and not each row to a single page.
EdIt: to clarify, each label is being sent to a zebra thermal printer and follows a similar format to a UPS or FedEx shipping label. Each row in the table will be one shipping label.
The key for you to understand is how SSRS handles Page Breaks. I have a similar answer here.
Whatever formatting you have for your labels should be placed inside a Rectangle.
Place this rectangle into a table with one cell that is grouped by label ID.
Set the group to page break between instances.
This makes the report repeat one instance of the label on each page. It can be a little tricky to understand at first, but it is a very useful trick. I have used this for reports like invoices where we needed one on each page.

SSRS 2005 unwanted page breaks between subreports

I have a report that has one table with two rows. The first row is just a header, the second is a subreport. The subreport consists of a single table. I want to pass one parameter into the subreport (Fields!patient_id.Value) and have the subreport repeat for every patient id. I have that working, but for some reason it inserts a pagebreak after every instance of the subreport when I look at the print preview, even though it could easily fit four of them on one page. I haven't set anything to insert a pagebreak at any place in the report or the subreport. I do want the page to break, but only when there is not enough room on the page to fit an entire subreport.
I've done enough troubleshooting to be able to say for certain that it is the subreport control or the subreport itself that is causing the problem, not the table. Any help would be appreciated.
Edit: It's also important to note that when I preview my subreport, there are no page breaks.
I found a solution. Instead of putting the subreport into the table, I put it into a list with a grouping expression of "=Fields!patient_id.Value".
set the ConsumeContainerWhitespace = True on the Report Properties
default is set to false and it attempts to preserve the blank space next to your table

Reporting services only displaying the last row

I have built a report pretty basic just a table wiht 45 rows of data. Problem is its only showing one row of data and its the last row. It displays just fine in the dataset and proc. any suggestiosn?
The table is in the body of the report.
make sure the fields don't have first() or last() in them.
probably you have put the fields in the header of the report
build your first report with the report creation wizard and after change it the way you want it
or you can just try create a table in the detail part (not header nor footer) of your report and drag some fields from the datasource explorer into the table, after click the preview tab and you will some a table with some records. good luck
You could check if there are any filters associated with the dataset. Click on the Edit DataSet button and check the Filters tab.

Resources