MS Access Code

  • Thread starter Thread starter Melbourne
  • Start date Start date
M

Melbourne

When I close a form I want to check if another form is open, if it is I want
to requery it otherwise I just want to close the form.

Does anyone know if there is code that I can use on the Close that will do
that.

Thanks
 
Private Sub Form_UnLoad(Cancel As Integer)
If CurrentProject.AllForms("Form2").IsLoaded Then
Forms("Form2").Requery
End If
End Sub
 
Thanks Allen.

I have tried the code You supplied as below, Form name is "DailyPlan", I get
no errors but the form does not requery. Have I typed it wrong?

If CurrentProject.AllForms("DailyPlan").IsLoaded Then
 
What does the error message say?
Which line gives the error?
Does it compile? (Compile on Debug menu)

What version of Access? This requires 2000 or later.

Is DailyPlan a form on its own, or a subform?

Alternative syntax:
Forms!DailyPlan.Requery

(The suggested syntax was to make it easy to use a string variable for the
form name.)
 
Thanks Allen,

There was no error message, I use Access 2007 and your last selection has
worked.

Thank you very much for your help.
 

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