Closing a form

  • Thread starter Thread starter Jerry Anderson
  • Start date Start date
J

Jerry Anderson

I have a form that opens another form based on a selection from a list box.
Loading the new form is triggered by the AfterUpdate event. After the new
form opens, what is the code to close the original?
 
Jerry Anderson said:
I have a form that opens another form based on a selection from a list box.
Loading the new form is triggered by the AfterUpdate event. After the new
form opens, what is the code to close the original?


The code that opens the new form can also close the current form:

DoCmd.OpenForm, "frmNewForm"
DoCmd.Close acForm, Me.Name, acSaveNo

The above code uses the current form's Name property to supply the name of
the form to be closed. If you want to close some other form, say "FormB",
you could write:

DoCmd.Close acForm, "FormB", acSaveNo

The acSaveNo argument instructs Access not to save any design changes to the
form. Note that it has nothing to do with saving any modified *data* on the
form -- that will happen automatically when you close the form, so long as
there's nothing (data validation errors, for example) to prevent it.
 
Dirk Goldgar said:
The code that opens the new form can also close the current form:

DoCmd.OpenForm, "frmNewForm"
DoCmd.Close acForm, Me.Name, acSaveNo

The above code uses the current form's Name property to supply the name of
the form to be closed. If you want to close some other form, say "FormB",
you could write:

DoCmd.Close acForm, "FormB", acSaveNo

The acSaveNo argument instructs Access not to save any design changes to the
form. Note that it has nothing to do with saving any modified *data* on the
form -- that will happen automatically when you close the form, so long as
there's nothing (data validation errors, for example) to prevent it.


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

Works like a champ! Thanks!
 

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