热度 2|
8RXMd04I.rar
(2007-06-20 17:31:00, Size: 34 KB, Downloads: 4)
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方式添加,如有方法请告知.
|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )
GMT+8, 2024-11-25 06:48 , Processed in 0.074754 second(s), 15 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.