全部显示

PropertyParentField 属性

       

返回一个 PivotField 对象,该对象代表字段中属性所从属的字段。

expression.PropertyParentField

expression   必需。该表达式返回一个 PivotField 对象。

说明

只对是成员属性字段有效。

如果 IsMemberProperty 属性为 False,那么使用 PropertyParentField 属性将返回一个运行错误。

示例

本示例确定第四个字段中是否存在成员属性,如果存在,则确定属性所属的字段。Excel 将该信息通知用户。本示例假定数据透视表位于活动工作表上,并且基于联机分析处理 (OLAP) 数据源。

Sub CheckParentField()

    Dim pvtTable As PivotTable
    Dim pvtField As PivotField

    Set pvtTable = ActiveSheet.PivotTables(1)
    Set pvtField = pvtTable.PivotFields(4)

    ' Check for member properties and notify user.
    If pvtField.IsMemberProperty = False Then
        MsgBox "No member properties present."
    Else
        MsgBox "The parent field of the members is: " & _
            pvtField.PropertyParentField
    End If

End Sub