注册 登录
Office中国论坛/Access中国论坛 返回首页

的个人空间 http://www.office-cn.net/?0 [收藏] [复制] [分享] [RSS]

日志

[原创]重新指定数据透视表数据源小实例

热度 2已有 2151 次阅读2008-4-26 10:35 |个人分类:Access


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方式添加,如有方法请告知.

刚表态过的朋友 (0 人)

发表评论 评论 (1 个评论)

回复 JosephTan 2012-2-17 12:24
这是什么?

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-12-27 14:45 , Processed in 0.057810 second(s), 15 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部