Determine if a form is open

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?
 
G

Graham Mandeno

Hi MDW

Use acSysCmdGetObjectState:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top