Platform SDK: CDO 1.2.1 |
The Parent property returns the parent of the object. Read-only.
Set objParent = object.Parent
Object
The Parent property in CDO returns the immediate parent of an object. The immediate parent for each object is shown in the following table.
The Parent property represents the immediate parent of the object, rather than the logical parent. For example, a folder contains a Messages collection, which contains Message objects. The Parent property for a message is the immediate parent, the Messages collection, rather than the logical parent, the Folder object.
The Session object represents the highest level in the hierarchy of CDO Library objects and its Parent property is set to Nothing.
For more information on the CDO Library object hierarchy, see Object Model.
The Parent property does not correspond to a MAPI property and cannot be rendered into HTML hypertext by the CDO Rendering Library. Depending on the parent object returned, you might be able to render it as an object, by setting the ObjectRenderer object's DataSource property to the object returned by the Parent property, or as a container object, by setting the ContainerRenderer object's DataSource property to the collection object returned by the Parent property. See the DataSource properties for what objects are accepted.
This code fragment displays the Class of the parent Messages collection of a Message object:
' Function: Message_Parent Function Message_Parent() ' error handling here ... If objOneMsg Is Nothing Then MsgBox "Need to select a message; see Messages->Get*" Exit Function End If ' Immediate parent of message is the Messages collection MsgBox "Message immediate parent class = " & objOneMsg.Parent.Class ' error handling code ... End Function
To get to the Folder object, you have to take the parent of the Messages collection:
' Function: Messages_Parent ' Purpose: Display the Messages collection Parent class value ' See documentation topic: Parent property Function Messages_Parent() Set objMessages = objOneMsg.Parent ' error handling here ... If objMessages Is Nothing Then MsgBox "No Messages collection available" Exit Function End If MsgBox "Messages collection parent class = " & objMessages.Parent.Class Exit Function ' error handling here ... End Function