in MS Acces I'm opening a Dialog Form from another Dialog form.
So formA, opens formB. But they user can potentially open formB as standalone, I would like to avoid having errors in this case.
I thought about checking for and Existing parent for formB.
But when I do it I get still get the Error 2452: The expression you entered has invalid to the Parent property.
I tried:
If Not IsError(Me.Parent) Then
    Me.Parent.cboTraining.Requery
End If
And
If Not IsNull(Me.Parent) Then
    Me.Parent.cboTraining.Requery
End If
                You can test if a form is open using:
If Not CurrentProject.AllForms("someFormName").IsLoaded Then
Alternatively, when you open formB from formA, you could provide an openArg, which is easy to test.
This approach is similar to above: https://stackoverflow.com/a/53582533/4924078
Public Function hasParent(F As Object) As Boolean
'Inspired from: https://access-programmers.co.uk/forums/showthread.php?t=293282   @Sep 10th, 2019
   Dim bHasParent As Boolean
   On Error GoTo noParents
   bHasParent = Not (F.Parent Is Nothing)
   hasParent = True
   Exit Function
noParents:
   hasParent = False
End Function
Aimed to be more general, and could be called from both subforms/subreports, as below:
If hasParent(Me) Then
   msgbox "Has Parent :)"
   Me.Parent.text1 = "Yes"
else 
   msgbox "NO PARENTS .. :("
endif
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With