|
|
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 ' 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_Procedure: Exit Function Err_IsParentForm: Select Case Err.Number Case 2452 IsParentForm = True Case Else MsgBox Err.Number & ", " & Err.Description End Select Resume Exit_IsParentForm End Function
CODE If Not IsParentForm(Me) Then
'Requery the whole form, not just the subform Me.Parent.Requery End If
|
| This page was last modified 09:38, 6 April 2011. This page has been accessed 776 times. Disclaimers |