如何在vb6.0中的datareport中每次更改组头值

时间:2010-12-13 01:37:44

标签: vb6

我在vb6.0中开发应用程序我在这里使用datareport来显示报告我想在运行时为每个组头RptLabel分配值而不使用dataenvironment请告诉我实现这个

1 个答案:

答案 0 :(得分:0)

您需要为datareport创建一个hierarchical recordset以用作数据源。

首先,您需要将记录集的ActiveConnection属性设置为MsDataShape:

rsDataSource.ActiveConnection = "Provider=MsDataShape;Data Provider=None;"

以下是如何定义记录集结构的示例:

    rsDatasouce.Source = "SHAPE APPEND NEW adInteger As ParentId, " & _
    "New adVarChar(100) As HeaderValue1, " & _
    "New adVarChar(100) As HeaderValue2, " & _
    "((SHAPE APPEND New adInteger As ParentGroupId, " & _
                   "New adInteger As ChildGroupId, " & _
                   "New adVarChar(25) As ChildValue1, " & _ 
                   "New adVarChar(25) As ChildValue2, " & _
                   "((SHAPE APPEND New adInteger As ChildId, " & _
                                  "New adVarChar(8) As SubChildValue1, " & _
                                  "New adVarChar(100) As Description " & _
                     "RELATE ChildGroupId To ChildId) AS ChildDetail) " & _
       "RELATE ParentId To ParentGroupId) AS GroupDetail"

完成此操作后,您需要填充分层记录集。