Gustav Brock
gustav at cactus.dk
Fri Mar 14 05:09:00 CST 2003
Hi John
That's right. There are many variations on the error catching theme.
Did you see my two-liner on the same theme? Actually, I haven't paid
much attention to the hWnd property until I noticed that Drew uses it
quite a few places for his weird purposes.
Private Function IsSubform() As Boolean
On Error Resume Next
IsSubform = Me.Parent.hWnd
End Function
/gustav
> How about:
> 'IS THE FORM REFERRED TO IN THE PARAMETER (FRM) CURRENTLY LOADED AS A
> SUBFORM?
> Function ccIsSubForm(frm As Form) As Boolean
> Dim str As String
> On Error Resume Next
> str = frm.Parent.Name
> ccIsSubForm = (err = 0)
> On Error GoTo 0
> End Function
> If a form has a valid parent property then it is by definition embedded in
> another something. It may be in a tab control, or a form, but it will be a
> subform.
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
> -----Original Message-----
> From: accessd-admin at databaseadvisors.com
> [mailto:accessd-admin at databaseadvisors.com]On Behalf Of Gustav Brock
> Sent: Wednesday, March 12, 2003 2:17 PM
> To: Drew Wutka
> Subject: Re: [AccessD] How do I tell if a form is opened as a subform or
> not?
> Hi Drew
> I don't like at all coding where you rely on error generation. It may
> very well be quick and dirty code and some like that, but I try to
> use it as the last resort only.
> Previously I have posted this small function for the same purpose - it
> could have been for the benefit of Arthur "the static lover" as you'll
> see. It is not much larger than your code:
> <code>
> Private Function IsSubform() As Boolean
> Static booSubform As Boolean
> Static lngFormsCount As Long
> If lngFormsCount = 0 Then
> lngFormsCount = Forms.Count
> booSubform = StrComp(Forms(lngFormsCount - 1).Name, Me.Name,
> vbTextCompare)
> End If
> IsSubform = booSubform
> End Function
> </code>
> /gustav