How to check if a form is open.

  • Thread starter Thread starter Russ via AccessMonster.com
  • Start date Start date
R

Russ via AccessMonster.com

How can I check if a form is open, I would like to run some code only if
another form is open. How can this be done? Any help would be great.
 
SysCmd(acSysCmdGetObjectState, acForm, "NameOfForm") will return 0 if the
form's not open, or non-zero if it is.

You could also check whether or not it exists in the Forms collection: only
open forms are there.

Function FormIsLoaded(FormName As String) As Boolean
On Error Resume Next

Dim strName As String

strName = Forms(FormName).Name
FormIsLoaded = (Err.Number = 0)

End Function
 
The forms collection contains information on the forms that are
currently opened. Cylce through them looking for the name.

(Would post the code, but I'm exhausted after working 42 hours in the
last 3 days - do a google on 'function isLoaded' that should give you
some starting points and/or check Access VBA Help. The code is simple,
but my mind has checked out, I think its at a good Irish pub or an even
better Taverna.)

David H
 
Back
Top