你沒設置統計條件:
Dim Filter As String
With e.Form.Controls("StartDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("EndDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
Tables("2012年数据").Filter = Filter
End If
Dim g As New CrossTableBuilder("统计表1", DataTables("2012年数据"))
g.Caption = "下属企业经营情况"
g.HGroups.AddDef("下属企业")
g.VGroups.AddDef("经营范围")
g.Totals.AddDef("项目编号", AggregateEnum.Count, "项目编号")
g.HorizontalTotal = True
g.VerticalTotal = True
g.Filter =
Filter
g.Build()
MainTable = Tables("统计表1")