Include Two subreports (same report inserted twice) with different parameters for each report

Posted on 2008-11-19
Last Modified: 2012-05-05

I have a crystal report that has a number of subreports,I want to know if I can use the same subreport but pass different parameters twice.  In this case the first subreport is showing everything of a particular status and daterange and the other is showing everything outside this range.  I'm going to create a copy of the inserted sub report and pass the parameters via a dataset but would prefer if possible to not have to create a copy.  I'm using 2005 to populate the report.
Question by:geraintcollins

    Author Comment

    Oops spoke too soon, not sure how to specify two different sets of criteria on the same table in the dataset.  I guess I need 2 views unless there is another way.
           'Management Action Plan - Sub Report 2
            sSQL = "Select * from PlanTable where FPlanID = " & intPlanID
            myDS = GetDataSet(sSQL, "PlanTable")
            'Management Action Plan - Sub Report 2
            sSQL = "Select * from PlanTable where FPlanID = 7"
            myDS = GetDataSet(sSQL, "PlanTable")

    Open in new window

    LVL 100

    Expert Comment

    Assuming you are linking the main report to the subreports.

    Use the date range as part of the link and the selection criteria.

    Open each subreport for editting and change the selection criteria so the first one chooses values in the range and the second values NOT in the range.


    Author Comment

    That's a big help, thanks mimmc.

    What if I wanted to pass a parrameter to both of my sub reports from my web form do you know how I'd do that in code?

    e.g. I may want to have a field on my form that says status (report 1) status (report2) so that the two sub reports open with different sets of data.
    LVL 100

    Accepted Solution

    The easiest way is to put the parameter into the main report then use the subreport links to pass the values to the subreports.


    Author Closing Comment

    Thanks for your help!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video discusses moving either the default database or any database to a new volume.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now