Open Forms

G

Guest

Hello everyone,

I have a form which is called from two other ("parent") forms. Not both
"parent" forms are open at any given time. Is there a way to know which
"parent" form called the "child" form?

If not, Is there a way to know whether a form is open?

Thanks a lot,

Marios
 
K

Keith Wilby

Marios said:
Hello everyone,

I have a form which is called from two other ("parent") forms. Not both
"parent" forms are open at any given time. Is there a way to know which
"parent" form called the "child" form?

If not, Is there a way to know whether a form is open?

Thanks a lot,

Marios

Use the OpenArgs property when calling the form:

DoCmd.OpenForm "frmMyForm", , , , , , Me.Name

In the called form, get the name of the calling form:

Dim strCallingForm As String
strCallingForm = Me.OpenArgs

To determine if a specific form is open, use this:

Public Function libIsFormLoaded(ByVal strFormName As String) As Boolean
' Returns true if the specified form is open in Form View
Const cObjStateClosed = 0
Const cDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) Then
If Forms(strFormName).CurrentView <> cDesignView Then
libIsFormLoaded = True
End If
End If
End Function

Call the function like this:

If libIsFormLoaded("frmMyFormName") Then ...

HTH - Keith.
www.keithwilby.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top