Solved Closing an Open Form when a user select a New one (1 Viewer)

chickenwings23

New member
Local time
Today, 11:54
Joined
Jun 3, 2022
Messages
21
Hello! I have a MainMenu Form where a user can click on one form and it opens up to something. Is there a way for the MainMenu or previous form to close automatically?

MainMenu
frmBusiness (Example of form)

For example, a user selects a frmBusiness on the MainMenu, the MainMenu disappears in the background, then the frmBusiness opens up. The user fills in the information, etc. and now wants to go back to the MainMenu. The user clicks "MainMenu cmd button" on the frmBusiness and goes back to the MainMenu, but the frmBusiness form closes.

Its basically having One Form opening up and the previous one closes. Would appreciate the help! Thanks!!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:54
Joined
Oct 29, 2018
Messages
19,135
If you're using code from the main form to open the selected form, you can amend that code to close or hide the main form first.
 

chickenwings23

New member
Local time
Today, 11:54
Joined
Jun 3, 2022
Messages
21
Yes, I just have the Access Wizard command button to open the form, but what is the code to close or hide the main form first
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:54
Joined
Oct 29, 2018
Messages
19,135
For example,

DoCmd.Close acForm, Me.Name
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:54
Joined
Sep 21, 2011
Messages
10,838
Why specify a hardcoded name, when you already know the name? :(
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:54
Joined
Feb 19, 2002
Messages
36,837
Usually, when I open formB from formA, I'm going to want to go back to formA when I close formB. The technique to do that is to hide the current form after opening the new form rather than closing it and pass the name of the calling form in the OpenArgs. Here it is in action.
 

Attachments

  • ChainingForms.zip
    33.9 KB · Views: 35

Users who are viewing this thread

Top Bottom