Access forms: Combination of always-maximized and non-popup non-maximized windows

I have one form in my Access 2010 application (the Master Form) which opens when the application opens and remains open throughout. I want this form to be always maximised, and to resize when the Access window is resized, which I achieve with Docmd.maximize (in both the Open and Activate event). Minmax buttons are disabled, and the form isn't resizeable. Autocenter, AutoResize and FitToScreen are all True. It has No Borders and is not Moveable.

There are other forms (the Secondary Forms) in the application which open as Modal forms; I want these NOT to be able to be maximised nor minimised, but to be resizeable. They can't be opened as Pop-up forms because the user needs to access commands on the ribbon to use them effectively. Autocentre is False, AutoResize is True and FitToScreen is True. Border Style is Sizeable; MinMax buttons are disabled.

The database has "Overlapping windows" rather than "Tabs" and I want it to remain that way, so that the users can view the context in the Master Form when working in a Secondary Form.  The problem is, when a Secondary Form opens, it opens maximised. If the secondary form is resized (either by the user or using docmd.restore),  the Master Form un-maximises and doesn't change size with the Access window; it re-maximises when the Secondary Form closes.

I have tried using code in the Master Form open event (instead of docmd.maximise) to resize the Master Form to the Access Window as follows:

Type Rect
    x1 As Long
    y1 As Long
    x2 As Long
    y2 As Long
End Type
Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal _
    nCmdShow As Long) As Long
Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal _
    x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight _
    As Long, ByVal bRepaint As Long) As Long
Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
'Use following instead of GetWindowRect
Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect _
    As Rect) As Long

Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNORMAL = 1     

Public Sub MaximizeRestoredForm(pfrmF As Form)
         ' Comments:
         ' Params  : pfrmF
         ' Modified:

100      On Error GoTo PROC_ERR

         Dim MDIRect As Rect
         ' If the form is maximized, restore it.
110      If IsZoomed(pfrmF.hwnd) <> 0 Then
120          ShowWindow pfrmF.hwnd, SW_SHOWNORMAL
130      End If
         ' Get the screen coordinates and window size of the
         ' MDIClient area.
         'This is the line which is different
140      GetClientRect GetParent(pfrmF.hwnd), MDIRect
         ' Move the form to the upper left corner of the MDIClient
         ' window (0,0) and size it to the same size as the
         ' MDIClient window.
150      MoveWindow pfrmF.hwnd, 0, 0, MDIRect.x2 - MDIRect.x1, MDIRect.y2 - MDIRect.y1, True

160      Exit Sub

170      DisplaySimpleError "MaximiseRestoredForm" 'Report and log the error
180      Resume PROC_EXIT
190      Resume

     End Sub

Open in new window

Using this, the Secondary Forms still open maximised, but can be restored to their default size in VBA (docmd.restore) without affecting the Master Form. However, the Master Form does not resize when the Access window resizes.

I would be happy with a solution that either (a) provided the behaviour I'm looking for or (b) enabled me to use the ribbon in the secondary forms if they are defined as Pop-up forms.
Who is Participating?
conagramanConnect With a Mentor Commented:
im not 100% sure of what you want here. i made a sample database for you to take a look at.

this database is set to tabbed documents but the "display documents tabs" is unchecked - giving you the effect i think you want

it has one form maximize onload
and two forms that popup.
one is able to be resized the other cannot be resized.
the reason you cannot resize the one form is because the border style is set to something other than sizeable
i know that you dont want your forms to "popup" but if a form does not popup it will maximize hiding your other open form/forms
colevalleygirlAuthor Commented:
Ok -- I will look to see if that approach works in my app.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

i hope it helps
colevalleygirlAuthor Commented:
The situation I want is:

MasterForm always filling the whole Access application window and resizing with it.

Secondary Forms opening as resizeable windows (with the Ribbon usable) on top of the MasterForm, still leaving the MasterForm visible but not updateable.

If the Secondary Form is Popup and Modal (effectively Dialog), the Ribbon is unavailable. If the Secondary Form is Popup but not Modal, the ribbon is available but users can interact with the MasterForm while a Secondary Form is open, which gives me significant logic problems. So Popup but not Modal is not good..

I could try locking the controls on the MasterForm while the Secondary Form is open -- but it has two ActiveX tree controls that look dreadful when they're disabled, and two (variable) subforms which would also need to be rendered totally 'read-only'.
if a form is model the ribbon will be unavailable.
if you dont want the controls on your main form to be updateable  you could just close the main form then open it again once you close the other form.
colevalleygirlAuthor Commented:
If the form is modal, the ribbon is available -- at least that's the behaviour I'm seeing.
And closing the Masterform means it's unavailable to refer to.
sorry yes your right - if you using overlapping windows like you are
why do you want the masterform open while your other form is open. what is its function?
colevalleygirlAuthor Commented:
It's the form that provides the context in which the user is working. The Secondary Forms are opened either (1) to allow a bigger window in which to enter formatted text in a memo field in one or other of the subforms on the MasterForm; (2) to edit rarely used subsidiary details associated with the record in one or other of the subforms. But the way in which the application is used, it's essential for the user to see details that are on the subforms while completing the Secondary Forms.
i see... can you upload your database or some screen shots -  perhaps a different design would be what you need
colevalleygirlAuthor Commented:
Here's a screen shot showing the Masterform (with the tree controls) and two Secondary Forms opened one after the other. This is pretty well how I want it to look and behave except the MasterForm isn't maximised. (In the runtime version there is only one tab on the ribbon).

I think I shall look at what can be done instead of the ribbon if the Secondary Forms are opened as Pop-ups... which will allow me to use your original solution. Context menus, maybe. If that doesn't fly, I'll go live (mid January!) with the MasterForm not maximising -- at least then the users will see consistent behaviour, although they'll probably complain about resizing the MasterForm every time they start they app.
what on the ribbon do you need the users to be able to use? you could just hide it?
colevalleygirlAuthor Commented:
I want the users to be able to use: Text formatting, Find and Replace, and SpellCheck.

I'm making good progress with the context menu option, so will accept your original solution.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.