UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> IsParentForm    

Occasionally, we may have a Form object that may be used either by itself or as a source for a subform. In such situations, attempting to refer to form's Parent property will result in a runtime error. This functions provides a simple test so code that are meant to be run whenever form is opened as subform and not when it's opened by itself without any errors.

' Code courtesy of UtterAccess Wiki
' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary
' You are free to use it in any application,
' provided this copyright notice is left unchanged.

Public Function IsParentForm(frm As Form) As Boolean
On Error GoTo Err_IsParentForm

If Not frm.Parent Is Nothing Then
   IsParentForm = False
End If

   Exit Function
   Select Case Err.Number
       Case 2452
           IsParentForm = True
       Case Else
           MsgBox Err.Number & ", " & Err.Description
   End Select
   Resume Exit_IsParentForm
End Function

Example Usage:

If Not IsParentForm(Me) Then
  'Requery the whole form, not just the subform
End If

Creative Commons License
IsParentForm by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search

Thank you for your support!
This page has been accessed 4,679 times.  This page was last modified 09:38, 6 April 2011 by Jack Leach. Contributions by BananaRepublic  Disclaimers