Parent 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 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