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

Local time
Today, 10:52
Joined
Jun 3, 2022
Messages
38
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, 08:52
Joined
Oct 29, 2018
Messages
21,358
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.
 
Local time
Today, 10:52
Joined
Jun 3, 2022
Messages
38
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, 08:52
Joined
Oct 29, 2018
Messages
21,358
For example,

DoCmd.Close acForm, Me.Name
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:52
Joined
Sep 21, 2011
Messages
14,044
Why specify a hardcoded name, when you already know the name? :(
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:52
Joined
Feb 19, 2002
Messages
42,970
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: 103

Users who are viewing this thread

Top Bottom