Parent Property

Applies To

Bound Object Frame Control, Chart Control, Check Box Control, Combo Box Control, Command Button Control, Form Section, Image Control, Label Control, Line Control, List Box Control, Option Button Control, Option Group Control, Page Break Control, Rectangle Control, Report Section, Subform/Subreport 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 instance, you might insert an OrderDetail 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 will be the name of the form.

See Also

Form, Report Properties; Forms Collection; Me Property.

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 Formctl As Controlfrm = Forms!Ordersctl = frm.[Speedy Label]
' Returns name of control attached to label."The parent control is " & ctl.Parent.Namectl = frm.[Speedy]
' Returns name of control containing control."The parent control is " & ctl.Parent.Namectl = frm.[ShipVia]
' Returns name of form containing option group control."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