Results 1 to 2 of 2

Thread: subreport problem

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2003
    Posts
    56

    subreport problem

    Can u have multiple subreports in one report?
    If so how do u set the datasource?

    Dim DSOrders As New MDataset()
    filldataset(DSOrders)


    Dim RD As New MainReport() ' this is the mainreport.rpt
    Dim RO As CrystalDecisions.CrystalReports.Engine.ReportObject
    Dim SRO As CrystalDecisions.CrystalReports.Engine.SubreportObject
    Dim SubDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument


    RO = RD.ReportDefinition.Sections.Item("Section3").ReportObjects.Item("Subreport1")
    SRO = CType(RO, CrystalDecisions.CrystalReports.Engine.SubreportObject)
    SubDoc = SRO.OpenSubreport(SRO.SubreportName)
    SubDoc.SetDataSource(DSOrders)


    This works for the 1st subreport if there is only one subreport.

    I tried the same code with different variable names for the 2nd subreport and it displayed the 2nd report right and the 1st subreport came back empty.

    What is the best method to have multople subreports in a report?
    Each subreport is from different tables.

    Any help appreciated

    thanks

  2. #2
    Hyperactive Member D12Bit's Avatar
    Join Date
    Oct 2000
    Location
    Guatemala
    Posts
    373
    Sorry but I don't understand how do you access the external data...

    but anyway here it is what I do.

    I have several reports that have several SubReports (Graphics specifically), and for example, in one that I have 3 SubReports I do the Following:

    VB Code:
    1. Report.Subreport1.OpenSubreport.Database.SetDataSource rsGraph1
    2.     Report.Subreport2.OpenSubreport.Database.SetDataSource rsGraph2
    3.     Report.Subreport3.OpenSubreport.Database.SetDataSource rsGraph3

    That's it.

    The SubReports have the data!

    Hope this helps!
    "Who Dares Wins" - "Quien se Arriesga Gana"
    Mail me at:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width