check form is open

  • Thread starter Thread starter TK
  • Start date Start date
T

TK

Can you check through code to see if a form is open?

I want to create an "if statement" if there is code to check this.
 
Try evaluating the IsLoaded property of the AllForms collection, as follows:

If CurrentProject.AllForms("frmMyForm").IsLoaded Then
MsgBox "Form is loaded"
End If

hth,
 
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).

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
 
The allforms worked, thanks.


Fredg said:
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).

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

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
 
Back
Top