Parent Property

Applies To   ActiveX control, Application object, Bound Object Frame control, Chart control, Check Box control, Combo Box control, Command Button control, Controls collection, Form, Form section, Forms collection, Image control, Label control, Line control, List Box control, Module object, Modules collection, Option Button control, Option Group control, Page, Page Break control, Rectangle control, Report, Report section, Subform/Subreport control, Tab control, Text Box control, Toggle Button control, Unbound Object Frame control.

Description

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 form object or report object if the parent is a form or report.

Setting

The Parent property refers to a form, report, or control object and is read-only in all views.

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.

See Also   Collection property, Form, Report properties, Forms collection, Me property, Reports collection.

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.

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
The next example also returns the name of the form containing the option group control.

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