Link to home
Start Free TrialLog in
Avatar of ilyagzak
ilyagzak

asked on

How to link SSRS subreport to Main report

I am working in VB.NET VS 2015, SSRS
I have a main report and a subreport, both are based on the SQL Server stored procedures.
I populate both reports at form load events.
My subreport appears on the group level of the main reports.
Each appearance of the subreport should have only part of the data that is related to that particular group.
In other words, the supreport should take a parameter from the main report to display only relevant data.
 I tried to add a parameter field to the subreport and linked it to the field in the main report, but it get me an error Report cannot be shown. What do I do incorrectly?
Avatar of Vadim Rapp
Vadim Rapp
Flag of United States of America image

Where do you run this report - on SSRS server, or local within the application?
Avatar of ilyagzak
ilyagzak

ASKER

Within the application.
Let's say, report1 is main report, report2 is used in the subreport.

Make the copy of report2, then delete the datasource from it, and make all bound controls static. Run report2 and ensure that it works. Will report1 now show this modified report2 as subreport, or there's still error?
local within the application
Here what is happening now.
I declared a parameter on the subreport Report Data screen.
I added the same parameter on the main report Subreport Properties screen.
I assume that this parameter is going to the stored procedure that populates the subreport.
I wrote the stored procedure that returns all data if the parameter is empty, and returns the subset of data if parameter is not empty.
When I run the report the subreport comes up on each section of the main report, but it has all data, not just the subset that is relevant to that section.
I attached the screenshots from my report.
SubreportParameters.docx
So the "Report cannot be shown" problem is gone?

Re parameter, I would run sql server Profiler and saw how the stored procedure is being called.
My question is how to pass an AccountID parameter to each subreport in the code of the application to get AccountDetail subreport for each AccountID?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.