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

PROC_EXIT:
160      Exit Sub

PROC_ERR:
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.
colevalleygirlAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

conagramanCommented:
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
 Database11.accdb
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
conagramanCommented:
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
0
colevalleygirlAuthor Commented:
Ok -- I will look to see if that approach works in my app.
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

conagramanCommented:
i hope it helps
0
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'.
0
conagramanCommented:
if a form is model the ribbon will be unavailable.
0
conagramanCommented:
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.
0
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.
0
conagramanCommented:
sorry yes your right - if you using overlapping windows like you are
0
conagramanCommented:
why do you want the masterform open while your other form is open. what is its function?
0
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.
0
conagramanCommented:
i see... can you upload your database or some screen shots -  perhaps a different design would be what you need
0
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.
screenshot.jpg
0
conagramanCommented:
what on the ribbon do you need the users to be able to use? you could just hide it?
0
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.