<p>So I have an Access application, and I'd like some forms to be maximised when they are opened, and others to be medium-sized when they are opened.  However, if I try something like this:</p>

<pre><code>Private Sub Form_Activate()
  DoCmd.Maximize
End Sub
</code></pre>

<p>or</p>

<pre><code>Private Sub Form_Activate()
  DoCmd.Restore
End Sub
</code></pre>

<p>it has the effect of maximizing or restoring every open window, which isn't what I'm looking for.</p>

<p>Is there any way around this?</p>

<p>I'm using Access 2003.</p>

Access is an MDI (Multiple Document Interface) application, and this is how they work: either all sub-windows are maximized, or none.
What you need to do, is find a way to discover the dimensions of the Access application window, and then programmatically set the form's .InsideWidth and .InsideHeight properties. The
```
Application
```
object has a
```
hwndAccessApp
```
that probably can be used with some Windows API call to find out its width and height.
addendum
Thanks to
Philippe Grondier
for finding a relevant code sample, the general idea from the
code sample
is:
declare the following Win32 API elements:
```
struct Rect
```
(
```
Type Rect…
```
in VBA)
```
const SW_SHOWNORMAL = 1
```
(for ShowWindow)
```
GetParent
```
(given a hwnd, get its parent's hwnd)
```
GetClientRect
```
(retrieve position and size from a hwnd)
```
IsZoomed
```
(boolean; true if window is maximized)
```
ShowWindow
```
(change the state of a window)
```
MoveWindow
```
(to change the position and size of a window)
if your form is maximized (
```
IsZoomed(frm.hWnd) = True
```
), then restore it (
```
ShowWindow frm.hWnd, SW_SHOWNORMAL
```
)
get the MDI clients area from your form's hWnd (
```
GetClientRect GetParent(frm.hWnd, rect)
```
)
use the rect data to change the position and size of your window (
```
MoveWindow frm.hWnd, 0, 0, rect.x2-rect.x1, rect.y2-rect.y1
```
)
(The above is basically the explanation of the code sample; I didn't copy-paste the code because I wasn't sure if the author allowed it).