|
Private Sub cmd执行查询_Click()
Dim pTable As OWC10.PivotTable
Dim pFieldset As OWC10.PivotFieldSet
Dim pField As OWC10.PivotField
Dim ptConstants, totNewtotal
Dim pTableView As OWC10.PivotView
Dim pAxis As OWC10.PivotAxis
Dim objQD As QueryDef
Dim strSQL As String
If Me.Combo3.Value = 1 Then
strSQL = "select * from 表1"
Else
strSQL = "select * from 表2"
End If
Me.查询1_子窗体.Form.RecordSource = strSQL
Set pTable = Me.查询1_子窗体.Form.PivotTable
Set ptConstants = pTable.Constants
Set totNewtotal = pTable.ActiveView.AddTotal("aa bbb", pTable.ActiveView.FieldSets("bbb").Fields(0), ptConstants.plFunctionSum)
pTable.ActiveView.RowAxis.InsertFieldSet pTable.ActiveView.FieldSets("aaa")
pTable.ActiveView.DataAxis.InsertTotal totNewtotal
pTable.ActiveView.DataAxis.InsertFieldSet pTable.ActiveView.FieldSets("bbb")
pTable.ActiveData.HideDetails
End Sub
为透视表时 可添加总计字段
为透视图时 总计字段不能以vba方式添加,如有方法请告知. |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|