Search code examples
crystal-reportsreport

Crystal report second subreport causes missing parameter values error


I have a crystal report that includes two sub reports and it causes missing parameter values error on the call of ExportToDisk. It is working just fine with subreport[0], and the error comes after subreport[1] is added.

Am I doing wrong on using a subreport[1]? Any advise would be greatly appreciated.

Thanks,

        using (ReportClass rptH = new ReportClass())
        {
            rptH.FileName = "Report.rpt";
            rptH.Load();

            List<SampleDetails> aDetails = new List<SampleDetails> ();
            aDetails = GetADetailsData();
            rptH.SetDataSource(aDetails);

            List<SampleHeader> aHeader = new List<SampleHeader>();
            aHeader = GetAHeaderData();
            rptH.Subreports[0].SetDataSource(aHeader);

            List<SampleData> aFooter = new List<SampleData> ();
            aFooter = GetAFooterData();
            rptH.Subreports[1].SetDataSource(aFooter);

            sPath = "Output.pdf");

            FileStream fs1 = new FileStream(sPath, FileMode.OpenOrCreate, FileAccess.Write);
            fs1.Close();

            rptH.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, sPath);
        }

Solution

  • rptH.Subreports[1].SetParameterValue("@your parameter namme", parametervalue);
    

    try this.