passing a value from subreport to main report

  • Hi,

    I have not been able to find an answer to this anywhere.

    I have a report that is trying to assign traffic lights to different exposures in a portfolio.

    For each exposure I have a flag for a "sector" to say in which sector a particular counterparty works. I have targets for sectors and if the portfolio falls outside of the targets, a flag should become active and ALL exposures in that particular sector should be marked with that flag.

    In order to sum the exposures in each sector, i have written another report which uses a parameter to determine the sector i want the total exposure to be calculated.

    This subreport is now embedded in the main report and the sector for each exposure is passed to the subreport. So this works perfectly well.

    Now, my problem is that my subreport returns a value that I cannot refer to in any way. So say my subreport name is 'Sector' and the field name is "Sum_NBV" - in my main report I would like to say sth like '=ReportItems!Sum_NBV.Value' or maybe '=ReportItems!Sector.Sum_NBV.Value'

    but it doesnt seem to work

    Any ideas?

    Thanks

    Konrad

  • I don't think you can reference a value from a subreport in a main report.

  • Actually you can, I've just done it after a bit of scrabbling about; it doesn't seem to be listed anywhere on the web!

    What you'll need to do is put in an absolute reference, like so: [Reports]![YourReportName]![YourSubReportName]![TheValueFromTheSubReportYouWantToReference].

    Worked for me anyway - I think it's because you can only reference open reports/forms, so you can't point straight to the sub report as it isn't open on it's own terms, you have to reference it as it currently exists through the main report.

    Hope this helps. 😉

  • ok this is interesting, but cant get it to work

    what do i put into an expression when:

    -my report is called: Traffic_Lights.rdl

    -my subreport is called Sector.rdl

    -the subreport item i want to reference is called Sector_Score.rdl

    i was thinking of

    =[Reports]![Traffic_Lights]![Asset]![Asset_Score.Value]

    but that doesnt seem to work

  • Ah, well, first off I'm coming at it from an Access SQL point of view, so what works there may not work elsewhere... but, try losing the last bit where you specify the value, I think it should choose the value by default. But again, that works in Access, my knowledge of more general SQL is limited.

  • it seems to have a problem with [Reports] - its an unrecognized identifier

  • Ah, that would have been the Access slant - is it working now?

  • yhh no

    i kinda dont know how to refer to a report

    i can refer to an item in the active report by using reportitems!

    but refering to a different report needs a different class/identifier which i do not know

  • Hi.

    If your sub-report is just that, and you want it to show the detail information of a PO#, then you should be able to use the Master/Child link properties of the sub report object. To get to the subreport object, bring up the main report in Design view, then click ONLY ONCE on the subreport. Then open the Properties window and it should say that it is for a subreport (Subform/Subreport, and the name of the subreport object. Under the Data tab, you will find the Master and Child Link properties. Here is where you would put the name of the PO# as found on the Main report (Master Link) and the name of the PO# as found on the subreport (Child Link).

    By the way, I want to say that you can have a try of RAQ Report to make main-sub report easily. It provides 3 kinds of main-sub report for web report developers, Single-Table Main-sub Report, Embedded Main-Sub Report and Imported Main-Sub Report.

    If you like, you can get a free edition at http://www.raqsoft.com/download/install-package/.

    Regards,

    becklery.

    RAQ Report: Web-based Excel-like Java reporting tool[/url]

  • hi

    thanks for your help but i think this is for ssrs2008 and i only have the 2005 ver

    will try it out when i get a new one though

    unless you find a way of doing the same thing in 2008

    cheers

  • You need to use a Shared variable.

    In the subreport create a formula that contains/calculates the value you want to pass across. Something like

    Code:

    Shared currencyVar TotalAmount := Sum ({[Order Details].Amount});In the main report create a formula that uses this shared variable. Something like

    Code:

    Shared currencyVar TotalAmount;

    If TotalAmount > 1000 then

    TotalAmount * .1

    Else

    TotalAmount * .05Both formulas must use the exact same variable declaration. See the help file for more info on creating variables.

    RAQ Report: Web-based Excel-like Java reporting tool[/url]

  • this sounds like a great idea, thanks man

    will try it out later today/tmr and report back with any feedback here

  • OK

    it doesnt work for me

    Here's what I've done:

    in the subreport, I added the following code:

    public shared function region_score() as single

    report_score=reportitems!textbox1.value

    end function

    in the main report, I added the following code:

    public shared function subreport_region_score()

    subreport_region_score=region_score

    end function

    and i got the following error:

    Name 'region_score' not defined

    Any solutions? What have I done wrong? Can this be done?

    Also, I have done some google'ing and found one (but only one) website telling me that one cannot share variables between reports.

    Wrrr

    Maybe switching to SSRS 2008 would solve all this.

  • becklery (12/18/2009)


    Hi.

    If your sub-report is just that, and you want it to show the detail information of a PO#, then you should be able to use the Master/Child link properties of the sub report object. To get to the subreport object, bring up the main report in Design view, then click ONLY ONCE on the subreport. Then open the Properties window and it should say that it is for a subreport (Subform/Subreport, and the name of the subreport object. Under the Data tab, you will find the Master and Child Link properties. Here is where you would put the name of the PO# as found on the Main report (Master Link) and the name of the PO# as found on the subreport (Child Link).

    Where do you find Master/Child link properties? Can anyone explain more clearly how to do this, I have SSRS 2008.

  • konrad.blocher (1/6/2010)


    OK

    it doesnt work for me

    Here's what I've done:

    in the subreport, I added the following code:

    public shared function region_score() as single

    report_score=reportitems!textbox1.value

    end function

    in the main report, I added the following code:

    public shared function subreport_region_score()

    subreport_region_score=region_score

    end function

    and i got the following error:

    Name 'region_score' not defined

    Any solutions? What have I done wrong? Can this be done?

    Also, I have done some google'ing and found one (but only one) website telling me that one cannot share variables between reports.

    Wrrr

    Maybe switching to SSRS 2008 would solve all this.

    Did you ever work this one out as I've been searching a lot for this and still can't work out what to do.

    Thanks

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic. Login to reply