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?
>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.

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Jerry Anderson - 21 Mar 2008 19:31 GMT
> >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
[quoted text clipped - 15 lines]
> form -- that will happen automatically when you close the form, so long as
> there's nothing (data validation errors, for example) to prevent it.