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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Try this:

If CurrentProject.AllForms("FormName").IsLoaded = True Then…
 
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
 

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

Back
Top