How do detect if a form is open

morlan

Registered User.
Local time
Today, 11:56
Joined
Apr 23, 2003
Messages
143
I have a report and it needs to run a differnet routine depending on what form is open.

eg.

If frmApple = Open then
run this
else

run this

end if



Can this be done?
 
Do a search for IsOpen in the Forms section of this Forum. There's several that deal with this
 
You need to create the Function IsLoaded in a module:

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
End If

End Function

It can then be called from any event in a form:

If IsLoaded("frmName") Then
'Usually refresh the data

Else


End If


HTH
Dave
 

Users who are viewing this thread

Back
Top Bottom