Code Samples for Businesses, Schools & Developers

First Published 6 June 2026



This article was prompted by a client request to a former Access MVP:

The client is using overlapping windows display. He wants to maximize a popup form (Form2) to the full size of his screen using the Maximize button in the form title bar.
There is a button on this form, that hides the form and opens or makes visible the main menu.
On the main menu, there is a button which checks to see whether Form2 is loaded.
If so, it sets the visible property of the form to True. But this does not restore the form to its maximized state.

The issue here is that when one form is open in a restored state, Access applies that state to all subsequently opened forms. Similarly, if the calling form is maximized, all subsequently opened forms will also be maximized. VBA code must be used to manage the load state of each form individually.

The attached example database shows one method of achieving this result.

It contains two forms, frmMain and Form2. When frmMain is opened from the navigation pane followed by Form2, both open in their restored state:

Two forms
However if Form2 is opened first, it is maximized. If frmMain is then opened, code in its Activate event ensures it opens restored. Immediately Form2 also becomes restored.

To replicate the client's requirements, when the app is opened the AutoExec macro first opens the main form, frmMain, then opens Form2 hidden (and also restored).

Autoexec macro
The code in form frmMain is very simple:

Private Sub Form_Activate()
DoCmd.Restore
End Sub

Private Sub cmdForm2_Click()
If CurrentProject.AllForms("Form2").IsLoaded Then
Forms!Form2.Visible = True
Forms!Form2.MaximizeForm
End If
End Sub


As stated above, the Activate event code ensures frmMain always opens in its restored state.
The button click event opens Form 2 then maximizes it using a public event MaximizeForm in Form2.

The code in form Form2 is also very straightforward:

Private Sub Form_Load()
DoCmd.Restore
Me.Visible = False
End Sub

Public Sub MaximizeForm()
DoCmd.Maximize
Me.Visible = True
End Sub

Private Sub cmdMain_Click()
Me.Visible = False
DoCmd.OpenForm "frmMain"
End Sub


The Form_Load event ensures the form opens both hidden and restored. This is bypassed here as the form has already been opened from the autoexec macro.
The MaximizeForm subprocedure maximizes the form then makes it visible. It is a public event so it can be called from frmMain.
The button click event hides the form and opens frmMain, which also means the hidden form is now restored again.

That's it. QED!


Download

Click to download the example app:           Maximize Form Popup_v1.1      ACCDB - Approx 0.4 MB (zipped)

As is the case for all files downloaded from the internet, first unblock the downloaded file, unzip then save to a trusted location.
For more details, see my article: Unblock downloaded files by removing the Mark of the Web



Feedback

Please use the Email button in the contact form below to let me know whether you found this article useful or if you have any questions.

Please also consider making a donation towards the costs of maintaining this website. Thank you

Colin Riddington Mendip Data Systems Last Updated 6 June 2026




Return to Code Samples Page




Return to Top