[AccessD] How do I tell if a form is opened as a subform or not?

Gustav Brock gustav at cactus.dk
Wed Mar 12 11:14:00 CST 2003


Hi Drew

That was an awful lot of code to replace something like these two
lines: 

<code>

Private Function IsSubform() As Boolean

  On Error Resume Next
  IsSubform = Me.Parent.hWnd
    
End Function

</code>

/gustav


> This is from my new MiniCalendar database....still in development...but the
> function works fine.

> Private Function AmIASubForm() As Boolean
> On Error GoTo ErrorHandler
> Dim varTemp
> varTemp = Me.Parent
> AmIASubForm = True
> Exit Function
> ErrorHandler:
> Err.Clear
> AmIASubForm = False
> End Function

> -----Original Message-----
> From: Bruce Bruen [mailto:bbruen at bigpond.com]
> Sent: Tuesday, March 11, 2003 6:58 PM
> To: AccessD
> Subject: [AccessD] How do I tell if a form is opened as a subform or
> not?


> Hi List,

> I am trying to use a form that may appear as a subform or on its own.
> If it's a subform then I want to maximise it in its parent control
> space, if not then it should be sized to fit the form.
> But how do I tell where it is being opened?  The following doesn't work:

>     On Error Resume Next
>     If Not IsNull(Me.Parent.Name) Then
>         boolIsSubform = True
>         DoCmd.Maximize
>     Else
>         boolIsSubform = False
>     End If
>     On Error GoTo 0

> Ignore the fact that the docmd works on the parent, I am not worried
> about that at the moment, only that I don't know how to test the
> "subformedness".




More information about the AccessD mailing list