close 1 form while opening another

G

Guest

I am having an issue with closing the form named "RINSEform" The problem is
that when i click on RINSEform button it opens the new form but does not
close MAINform. My question is "what is the easier way to do this?" I have it
set so that when the user clicks a form to be opened from the main form it
closes the main upon form load. This worked fine when i had a few but now im
up to at least 11 forms and I would like to be able to add more.

This is what is in the form load for the MAINform
DoCmd.Close acForm, "GLYBATform", acSaveNo
DoCmd.Close acForm, "AMINEBATform", acSaveNo
DoCmd.Close acForm, "ESTERBATform", acSaveNo
DoCmd.Close acForm, "GRANULEform", acSaveNo
DoCmd.Close acForm, "AMINERAILout", acSaveNo
DoCmd.Close acForm, "AMINEtruck", acSaveNo
DoCmd.Close acForm, "DRYBATform", acSaveNo
DoCmd.Close acForm, "ESTERRAILout", acSaveNo
DoCmd.Close acForm, "GLYPACKform", acSaveNo
DoCmd.Close acForm, "GLYrailOUT", acSaveNo
DoCmd.Close acForm, "GLYtruck", acSaveNo
DoCmd.Close acForm, "ESTERTRUCKout", acSaveNo
DoCmd.Close acForm, "Inbound Glyphosate Material", acSaveNo
DoCmd.Close acForm, "AMINEtruckout", acSaveNo
DoCmd.Close acForm, "0inESTERMat", acSaveNo
DoCmd.Close acForm, "inbAMINEMat", acSaveNo
DoCmd.Close acForm, "RINSEform", acSaveNo

This is what is in the form load for RINSEform
Private Sub Form_Load()
DoCmd.Close acForm, "MAINform", acSaveNo

End Sub
 
V

Van T. Dinh

Instead of using the Form_Load Event of RINSEform, you should close the
Mainform in the CommandButton_Click Event procedure that open the RINSEform.

The code for the CommandButton_Click Event should be something like:

DoCmd.OpenForm "RINSEform", ...
DoCmd.Close acForm, "MAINform", acSaveNo
 

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

Top