Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Parent Property [Access 2003 VBA Language Reference]

Office 2003

You can use the Parent property to refer to the parent of a control, section, or control that contains other controls. The Parent property returns a control object if the parent is a control; it returns a AccessObject object if the parent is an Microsoft Access object. Read-only.

expression.Parent

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks

You can use the Parent property to determine which form or report is currently the parent when you have a subform or subreport that has been inserted in multiple forms or reports.

For example, you might insert an OrderDetails subform into both a form and a report. The following example uses the Parent property to refer to the OrderID field, which is present on the main form and report. You can enter this expression in a bound control on the subform.

=Parent!OrderID
		

The Parent property of a label control is the control the label is linked to. The Parent property for a check box, option button, or toggle button in an option group is the name of the option group control. The Parent property of an option group control is the name of the form.

Example

The following example uses the Parent property to examine the parent of the Speedy Label label control, the Speedy check box control, and the ShipVia option group. To run this example, open the Orders form in the Northwind sample database then run this code.

Public Sub ShowParent()

    Dim frm As Form
    Dim ctl As Control
    
    Set frm = Forms!Orders
    Set ctl = frm.[Speedy Label]
    
    ' Returns name of control attached to label.
    MsgBox "The parent control is " & ctl.Parent.Name
    Set ctl = frm.Speedy
    
    ' Returns name of control containing control.
    MsgBox "The parent control is " & ctl.Parent.Name
    Set ctl = frm.ShipVia
    
    ' Returns name of form containing option group control.
    MsgBox "The parent control is " & ctl.Parent.Name

End Sub

		

The next example also returns the name of the form containing the option group control.

MsgBox Forms!Orders![Speedy Label].Parent.Parent.Parent.Name
		


Show: