The information in this article applies to:
- Microsoft Access versions 1.0, 1.1, 2.0
SYMPTOMS
Moderate: Requires basic macro, coding, and interoperability skills.
When you maximize a form, all other open forms are also maximized. You
cannot maximize one form independent of the other open forms.
CAUSE
Microsoft Access is a multiple document interface (MDI) application. The
default behavior for an MDI document is for all child windows to be
maximized when one is maximized. This behavior occurs in many applications.
For example, if you maximize one group window in Windows Program Manager,
any other group window that you select (using the Window menu) will also be
maximized. Or, if you maximize a document window in Microsoft Word for
Windows, all other document windows will be maximized as well.
RESOLUTION
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information on Access Basic, please refer
to the "Introduction to Programming" manual in Microsoft Access version
1.x, or the "Building Applications" manual in version 2.0.
There are two ways to work around this behavior:
- Forms whose PopUp property is set to Yes are not MDI child windows.
Pop-up forms float on top of other forms, and are not maximized when
an MDI child window is maximized.
- You can simulate maximizing a form by sizing it as large as possible
in a restored state. The following example demonstrates how to create
and use a sample Sub procedure called MaximizeRestoredForm to restore a
form if it is maximized, and then move the form to the upper left corner
of the Microsoft Access client area window and size it as large as
possible.
NOTE: In the following sample code, an underscore (_) at the end of a
line is used as a line-continuation character. Remove the underscore
from the end of the line when re-creating this code in Access Basic.
1. Create a new module and enter the following lines in the
Declarations section of the module:
Option Explicit
Type Rect
x1 As Integer
y1 As Integer
x2 As Integer
y2 As Integer
End Type
Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, _
lpRect As Rect)
Declare Function IsZoomed Lib "User" (ByVal hWnd As Integer) _
As Integer
Declare Sub ShowWindow Lib "User" (ByVal hWnd%, ByVal nCmdShow%)
Declare Sub MoveWindow Lib "User" (ByVal hWnd As Integer, _
ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As _
Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer)
Declare Function GetParent Lib "User" (ByVal hWnd As Integer) _
As Integer
Const SW_MAXIMIZE = 3
Const SW_SHOWNORMAL = 1
2. Enter the following Sub procedure in the module:
Sub MaximizeRestoredForm (F As Form)
Dim MDIRect As Rect
' If the form is maximized, restore it.
If IsZoomed(F.hWnd) <> 0 Then
ShowWindow F.hWnd, SW_SHOWNORMAL
End If
' Get the screen coordinates and window size of the
' MDIClient window.
GetWindowRect GetParent(F.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.
MoveWindow F.hWnd, 0, 0, MDIRect.x2 - MDIRect.x1, _
MDIRect.y2 - MDIRect.y1, True
End Sub
3. To automatically simulate maximizing a form when the form is opened,
set the form's OnLoad property to the following event procedure:
Sub Form_Load()
MaximizeRestoredForm Me
End Sub
4. To simulate maximizing a form called MyForm, use the following
statement in a function or subroutine:
MaximizeRestoredForm Forms!MyForm
STATUS
This behavior is by design.
REFERENCES
For more information about pop-up forms, search for "PopUp" then "Creating
Pop-Up Forms and Dialog Boxes" using the Microsoft Access version 2.0 Help
menu.
|