'------ start of function code ------
Function ParentSubformControl( _
                    frmMe As Access.Form) _
            As Access.SubForm

    Dim frmParent As Access.Form
    Dim ctl As Control

    On Error Resume Next
    Set frmParent = frmMe.Parent
    If Err.Number <> 0 Then
        ' This is not a subform.
        Set ParentSubformControl = Nothing
        For Each ctl In frmParent.Controls
            If ctl.ControlType = acSubform Then
                If ctl.Form Is frmMe Then
                    Set ParentSubformControl = ctl
                    Exit For
                End If
            End If
        Next ctl
    End If

    Set ctl = Nothing
    Set frmParent = Nothing

End Function
'------ end of function code ------