Detecting if a form is active

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone help me make this work? I know there is a way I just am stumped.

If Forms![Inland Marine]![Inland Marine] "IS ACTIVE" Then Me.Inland_Marine =
Forms![Inland Marine]![Inland Marine]

Thank you so much for your help

Mallory
 
You first need to write a function that uses the Syscmd method like this:

Function isLoaded(ByVal strFormName As String) As Boolean
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
isLoaded = True
End If
ElseIf SysCmd(acSysCmdGetObjectState, acReport, strFormName) <>
conObjStateClosed Then
isLoaded = True
End If
End Function

Next change your code to read:

If isloaded("Inland Marine") then
Me.Inland_Marine = Forms![Inland Marine]![Inland Marine]
End If
Can someone help me make this work? I know there is a way I just am
stumped.

If Forms![Inland Marine]![Inland Marine] "IS ACTIVE" Then Me.Inland_Marine =

Forms![Inland Marine]![Inland Marine]

Thank you so much for your help

Mallory
 
I am confused!

Do you have a Form name "Inland Marine" and in this Form, you have a Control
(SubformControl???) named "Inland Marine'" also?

That is what you are referring to in the reference "Forms![Inland
Marine]![Inland Marine]" (which is not a reference to a Form , BTW).

If you want to check whether the Form "Inland Marine" is open or not and you
use A2K or later, you can use:

CurrentProject.AllForms("Inland Marine").IsLoaded

which returns True if the Form is loaded.
 
Back
Top