EnumAncestors

Returns an array containing the member IDs of a given member’s ancestors.

Syntax

<IHsvTreeInfo>.EnumAncestors lItemID, bIgnoreDups, pvaralIDs

Argument

Description

lItemID

Long (ByVal). The member ID of the member.

bIgnoreDups

Boolean (ByVal). Specifies whether duplicate member IDs are returned. Pass TRUE to filter out duplicates, FALSE to return duplicates.

pvaralIDs

Variant array. Returns the array of the ancestors’ member IDs. The array is returned as a Long subtype.

Example

The following function takes a dimension ID and a member label and returns the labels of the member’s ancestors.

Function getAncestors(lDim As Integer, sMem As String) As Variant
Dim lMember As Long, cTreeInfo As IHsvTreeInfo
Dim vaIDs, saLabels() As String
'g_cMetadata is an HsvMetadata object reference
Set cTreeInfo = g_cMetadata.Dimension(lDim)
lMember = cTreeInfo.GetItemID(sMem)
cTreeInfo.EnumAncestors lMember, False, vaIDs
'if the member has no ancestors, the return value is null
If IsEmpty(vaIDs) = True Then
    getAncestors = Null
    Exit Function
Else
    ReDim saLabels(UBound(vaIDs))
    For i = LBound(vaIDs) To UBound(vaIDs)
        cTreeInfo.GetLabel vaIDs(i), saLabels(i)
    Next i
    getAncestors = saLabels
End If
End Function