2010-01-30 104 views
1

更新:我在这里问一个更普遍的问题:Can I do two levels of linking in Crystal Reports?Crystal Reports:有没有办法在子报表中有效地获取子报表?

我使用VB.NET中的Crystal Reports和Visual Studio 2005

我有几个子报表的报告。我将List(Of MainStuff)设置为主报表的数据源。我将List(Of SubreportStuff)设置为子报表的数据源。每个SubreportStuff都有一个链接到特定MainStuff的键,因此报表将每个MainStuff项目与其相关的SubreportStuff项目分组。 (或者在DB级别,SubreportStuff项目有一个外键,它是MainStuff中的主键。)

下面显示了包含CrystalReportsViewer的对话框的加载函数。在Crystal Reports报表编辑器(在VS 2005中)中,我设置了子报表链接,以便只将相关项目拉入报表的那一部分。

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 

这工作正常。

现在,我需要做的事实质上是同样的事情,但是根据子报告项目中的键拉取项目。这意味着在子报表中有一个子报表。但是,我似乎没有做到这一点(当我尝试插入已经是子报表的东西时,插入子报表的选项会灰显)。

有没有办法可以做到这一点? (我能以某种方式将子报表关系降低到另一个级别吗?)

一如既往地感谢!

回答

3

子报表中的子报表在Crystal Reports中是不可能的。

+0

感谢您确认我的怀疑。有没有办法在子报表中包含项目列表,其中这个项目列表中有子报表项目作为主键? – John 2010-01-30 04:56:23

+0

我在这里概括了我的问题:http://stackoverflow.com/questions/2166963/can-i-do-two-levels-of-linking-in-crystal-reports – John 2010-01-30 05:27:16

+0

我不知道我理解你的问题。你的意思是'有没有办法将主要报告与子报告联系起来,子报告中的数据是基于主报告中的数据值?'?如果是这样,答案是'是的'。 在任何情况下,您都可以在不使用子报告的情况下实现预期的结果。首先将三个表格添加到您的报告并根据需要链接它们。接下来,为每个部门插入一个组:department_name,division_name和group_name。最后是利润。 – craig 2010-01-30 14:42:29

相关问题