views:

396

answers:

1

UPDATE: I asked a more general question here: http://stackoverflow.com/questions/2166963/can-i-do-two-levels-of-linking-in-crystal-reports

I'm using Crystal Reports within VB.NET and Visual Studio 2005.

I have a report with several subreports. I'm setting List(Of MainStuff) as the data sources for the main report. I'm setting List(Of SubreportStuff) as the data source for the subreport. Each SubreportStuff has a key which links back to a particular MainStuff, so the report groups each MainStuff item with its related SubreportStuff items. (Or, at the DB level, SubreportStuff items have a foreign key, which is the primary key in MainStuff.)

Below shows the Load function for the dialog, which contains a CrystalReportsViewer. In the Crystal Reports report editor (within VS 2005) I set the subreport link to pull only the related items into that part of the report.

Imports System.Windows.Forms

    Public Class dlgMyReport
        Private rpt As New MyReport
        Public theMainList As New List(Of MainStuff)
        Dim theSubreportList As New List(Of SubreportStuff)

        Private Sub dlgMyReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            rpt.SetDataSource(theMainList)

            If theSubreportStuff.Count > 0 Then
                rpt.Subreports.Item("subReport").SetDataSource(theSubreportList)
            End If

            Me.StuffViewer.ReportSource = rpt
        End Sub

        ... ' other subs and functions

    End Class

This works fine.

Now, though, what I'm needing to do is in essence the same thing, but pull items based on the keys in the subreport items. This would mean having a subreport within a subreport. However, it doesn't appear that I can do this (the option for inserting a subreport is grayed out when I try to insert in something that is already a subreport).

Is there a way that I can accomplish this? (Can I carry the subreport relationship down another level in some way?)

Thanks as always!

+2  A: 

Subreports within subreports are not possible within Crystal Reports.

Craig
Thanks for confirming my suspicions. Is there a way to include a list of items within a subreport where this list of items has the subreport item as a primary key?
John at CashCommons
I generalized my question here: http://stackoverflow.com/questions/2166963/can-i-do-two-levels-of-linking-in-crystal-reports
John at CashCommons
I'm not sure I understand your question. Do you mean, 'Is there a way to link the main report to the subreport, where the data in the subreport is based on a data value in the main report?'? If so, the answer is 'Yes.'.In any case, you can achieve your desired result without using a sub-report. Start by adding the three tables to your report and link them as desired. Next, insert a group for each: department_name, division_name, and group_name. Finally, profit.
Craig