Is one of these forms open?

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

Guest

I need to write a piece of code to check to see if one of 6 possible forms is
open. What is the best way to do this? I figure that a bunch of If...Else's
would not be the best way, but I can't quite figure out how to do it with a
Select Case. Can someone point me in the right direction? Thanks!
 
There is a IsLoaded function in Northwind sample database:
Function IsLoaded(ByVal strFormName As String) As Boolean
' 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


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
Thanks - I know about the Isloaded function and I'm using it, my question is
more about how to check for which one of the 6 forms is the one that's open,
using the IsLoaded function in some sort of Select Case statement so that I
don't have to write:

If IsLoaded ("FormA") then
'do what I want
End If

If Isloaded ("FormB") then
'do what I want
End if

....and so on...for 6 forms. The Forms won't all be open at the same time,
but at least 1 of the 6 will be. So I need to figure out which one is open.
So I'm looking a way to do this other than writing 6 If Then statements -
unless of course, that is the best way. Thanks again!
 
Tim Ferguson said:
set myForm = Screen.ActiveForm

"Open" <> "Active". But what Sandie wants isn't really clear to me.
Can there be only one of these six forms open at any given time? If
more than one of them is open, does she want to run the code that is
relevant to both of them, or just one of them -- and if the latter,
which one?
 
"Open" <> "Active". But what Sandie wants isn't really clear to me.
Can there be only one of these six forms open at any given time?

That's what I guessed, ("... which one of the six forms...") and she (he?)
seems happy with the result. I installed the Windows Telepathy Toolkit last
week and it seems to be working... <g>

Good point to keep an open mind, though.

All the best

Tim F
 
Back
Top