Showing results for 
Search instead for 
Did you mean: 

Crystal Reports - How to pass a parameter from Main Report to a subreport?

0 Kudos

Hi everybody,

I am developing a Crystal Report consisting of a Main Report and a Subreport (Say CR_Main1 and CR_Sub1)

Both reports use only 1 and the same parameter (say @BPCode).

Both reports derive their data from Stored Procedures (which I wrote in Management Studio).

Let's say they are called dbo. usp_main and dbo.usp_sub

I used dbo_usp_main as datasource to populate the main report. This process automatically creates the parameter @BPCode in CR_Main1

I then used dbo_usp_sub as datasource to populate the subreport. This process likewise creates the parameter @BPCode in CR_Sub1

Then I insert the Subreport into the Main Report.

When I run the Main Report, I get TWO blank fields in the Selection Criteria box to enter the BP Code.

I was expecting only ONE input field to appear.

I intend to add up to 10 subreports. So this means I must input the same BP Code in 11 boxes??

Can anyone give me an idea how to overcome the problem of multiple input boxes?

Since I need only one and the same @BPCode for all reports, I want only 1 input box.

The input will then be passed to all stored procedures.

I need to work with stored procedures as my reports are very slow without them.

The parameter needs to be passed to the sp, not CR so that they are run on server, and pass only a limited results set to CR

Any help is much appreciated.


Leon Lai

View Entire Topic
Active Contributor
0 Kudos

Hi Leon Lai Kan...

Right-click the sub-report and select 'Change Sub-report links'; You can do this for all the sub-reports....

Also check with this Link

Hope Helpful



0 Kudos

Hi Kennedy,

Your suggestion works wonders!

I did as you told me.

Now, there is only ONE input box in Selection Criteria, exactly what I wanted.

When I run the report, the Main Report is generated, together with a link to the subreport.

When I click on the link, the Subreport is genetrated - using the same parameter.

There is only one minor problem. While the main report runs very fast, the link to subreport is a bit slow - about 30 seconds (which is still fast to be fair)

I don't know if I have done the correct procedure.

So, I reproduce my (test) stored procedures for your comments

MAIN Stored Procedure

Alter procedure [dbo].[usp_Main1]

@ShortNme nvarchar(15)


SELECT TransId, Refdate, Debit, Credit, ShortName


Where ShortName = (@ShortNme)

SUB Stored Procedure

Alter procedure [dbo].[usp_Sub1]

-- (no input parameters)


SELECT TransId, ShortName


-- (no WHERE Clause)


I linked to ?@ShortNme

I am closing this thread shortly (to permit you to reply, if any) as Correct Answer

Thanks a lot