Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to check if a form is open or not? 1

Status
Not open for further replies.

emilybartholomew

Technical User
Aug 3, 2001
82
US
I have a set of interrelated forms. One of the forms I have ("Projects") has a button on it that opens a "Project Log" form. The user can enter notes, close the form, and I have some VB code that refreshes the Project form. However, I want to use the Log form even when the original Projects form is not open. Of course, vb gives me an error when I close the log form and it tries to refresh the projects form, which is not open. Is there a way to test if the Projects form is open or not? (Then a simple if statement would do the job...)

Thanks-

emily
 
Hi Emily,

Use the SysCmd Method. Here's an example:

Dim frmStatus as Integer

frmStatus = SysCmd(acSysCmdGetObjectState, acForm, "formname")

If frmStatus = 0 Then
' The form is not open
End If

SysCmd returns 0 if not Open, 1 if Open, 2 if Changed/not saved, and 4 if New, or any combination of the above if more than one are true.

You can use this method to check if the form is open, but it almost sounds like the form is being closed when it supposed to be open?

dz
 
Thanks. The SysCmd method works great! (I didn't try the other way, but I'm sure it's good too)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top