Re: Is one of these forms open?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



ok, then you can use such kind of loop:

Dim i as integer

For i = 0 To Forms.Count - 1
If Forms(i).Name Like "Form?" Then
msgbox "From Loaded: " & Forms(i).Name
Exit for
End If
Next

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Sandie" <Sandie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:B243D85B-A423-480C-A041-25A7479D3DE5@xxxxxxxxxxxxxxxx
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!


"Alex Dybenko" wrote:

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 Data***
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

"Sandie" <Sandie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9C25E798-721D-4770-94AF-251726FF76C0@xxxxxxxxxxxxxxxx
>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!



.


Quantcast