Is a form open?

K

Kevin

Dear all

How do I know that a form has been opened during run time?
I want to reference to Form1 from Form2, but I need to
know whether Form1 is open first. How do I check?

Thanks

Kevin
 
S

Steve

Look in the Northwind Traders example in the standard modules; there's a
function there for this. Also I think there's one at mvps.org/access.

Steve
 
F

Fredg

Kevin,
What version of Access?
Access 2002:
If Not CurrentProject.AllForms("FormA").IsLoaded Then
Do something here
Else
Do something else
End If

In Access 97, copy this function (from the Northwind.mdb sample
database) into a code module.

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet
view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
===
Then code:
If Not IsLoaded("FormA") Then
Do this
Else
Do that
End if
 

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