How can I check if a form is open before closing another?

S

stevie888

Hi

I have a form (frmSurvey) and a form that opens from this form
(frmQuestion3Reason).

Basically, when a user tries to close frmSurvey, i want to check that
frmQuestion3Reason is no longer open, and if it is, display a message box
telling the user to close the form?

Can anyone help?

Kind Regards

Steven
 
K

kingston via AccessMonster.com

Try this:

If CurrentProject.AllForms("FormName").IsLoaded = True Then…
 
D

Dirk Goldgar

stevie888 said:
Hi

I have a form (frmSurvey) and a form that opens from this form
(frmQuestion3Reason).

Basically, when a user tries to close frmSurvey, i want to check that
frmQuestion3Reason is no longer open, and if it is, display a message
box telling the user to close the form?

Are you aware that you can use DoCmd.Close to close the form if it's
open, and it won't generate any error if the form is not open? So your
frmSurvey could just automatically close frmQuestion3Reason whether it's
open or not.

If you really need to check if the form is open, so that you can take
some special action, you can use code like this:

If CurrentProject.AllForms("frmQuestion3Reason").IsLoaded Then
' ... the form is open ...
End If
 
Top