How to Hide and Restore Popup Forms in Microsoft Access
Question details
The user wants to hide an initial Microsoft Access popup form when opening a secondary detail form, and automatically restore the initial form's visibility when the detail form is closed.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Managing user interface flow between multiple popup forms in a database application to prevent screen clutter.
- Observed behavior
- The user needs to transition smoothly between popup forms without keeping the previous form visible, ensuring it safely restores when returning from the new form.
Ensure you have design access to your Microsoft Access database and are familiar with basic Visual Basic for Applications (VBA) events such as On Click and On Unload.
Use the Visible Property and Form Events
Hide the previous form using VBA code when opening the new form, and restore it using the Unload event of the new form.
This method involves toggling the form's visibility rather than closing it. By keeping the previous form open but hidden, it retains its data and state, making the transition seamless for the user.
Open your Access database, navigate to the initial popup form, right-click its tab, and select 'Design View'.
Select the command button used to open the detail form. In the Property Sheet, go to the 'Event' tab, click the ellipsis (...) next to 'On Click', and choose Code Builder. Add the code: Forms!YourInitialFormName.Visible = False right after the DoCmd.OpenForm command.
Open the secondary detail form in Design View. In its Property Sheet, select 'Form' as the selection type. Go to the 'Event' tab, find the 'On Unload' event, and open the Code Builder. Add the code: Forms!YourInitialFormName.Visible = True.

Open Detail Forms in Dialog Mode
Use the WindowMode parameter to open the secondary form as a dialog, pausing the execution of code on the previous form until the dialog closes.
Need a Free Alternative to Microsoft Office?
While WPS Office does not include a database management tool like Microsoft Access, it offers an exceptional, free alternative for your daily document, spreadsheet, and presentation needs. It features high compatibility with standard Office files.
- 1. Visit the WPS Office Website: Navigate to the official WPS Office website to find the free download link.
- 2. Download the Installer: Click the 'Free Download' button to get the latest installation package for your device.
- 3. Install and Start Creating: Run the installer, follow the on-screen instructions, and start handling your documents with ease.

Frequently Asked Questions
Why doesn't the previous form restore when using a custom Close button?
If the code to restore the form's visibility is only placed in a custom command button's On Click event, it will not execute if the user dismisses the form using the default window close button ('X'). Using the Form_Unload event ensures the code runs regardless of how the form is closed.
Can I pass data between the hidden popup form and the detail form?
Yes. Even when a form's Visible property is set to False, it remains open in memory. You can continue to read and write data to its fields by explicitly referencing them, such as using Forms!HiddenFormName.ControlName.
What is the difference between hiding a form and closing a form in Microsoft Access?
Hiding a form (setting Visible = False) keeps the form active in the background, retaining all user inputs and its current execution state. Closing a form using DoCmd.Close completely removes it from memory, resulting in the loss of unsaved temporary states.




