Determine if a form is open

  • Thread starter Thread starter MDW
  • Start date Start date
M

MDW

Is there a way using VBA that I can check to see if a
particular form is open?

I'm in Access 97, and I want to put some code on form A,
and check if form B is open. Something like this:

Private Sub cmdOpen_Click()

' This module lives in form A, which opens when the
database does

For each objForm in Forms

If objForm.Name = "form B" And objForm.Open Then

' Do something

End If

Next

Unfortunately, I can't seem to locate a property
like "Open" or "IsOpen" or whatever.

I use a loop because I may want to check for different
forms at different times. Any ideas?
 
Hi MDW

Use acSysCmdGetObjectState:

If SysCmd(acSysCmdGetObjectState, acForm, sFormName) Then
' form is open
Else
' form is closed
End If
 
Back
Top