ms-accessms-access-2013

VBA Access check if Parent form exists


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

Solution

  • 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.