Detect if another form is already open.

  • Thread starter Thread starter Dazza
  • Start date Start date
D

Dazza

I know this can be done but have forgotten the code syntax.

What I want to do is, when a user exits a form, detect if other forms/a
specific form is still open.

A reminder of the code is appreciated.

Regards
Dazza
 
I know this can be done but have forgotten the code syntax.

What I want to do is, when a user exits a form, detect if other forms/a
specific form is still open.

A reminder of the code is appreciated.

Regards
Dazza

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) to a 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 in an event:
If Not IsLoaded("FormA") Then
Do this
Else
Do that
End if
 
Fred you are a diamond.

The old command CurrentProject.AllForms().IsLoaded.

It is amazing how easy code syntax is to forget when you havn't used it for
a while.

Many thanks

Dazza
 
Back
Top