title: Use Z-order and position to organize open forms in MS Access
body: <p>For MS Access 2010, I need a way to flexibly maintain the position and Z-order when a dozen forms are open.  There can be multiple instances of the Parent form, and each one can lead to multiple instances of the Child form (some <a href="https://stackoverflow.com/q/22108012/122139">background here</a>).</p>
  
  <p>I want the user to be able to choose which form is top-most -- which means I don't want any forms set as <code>Popup</code>.  Also, I want the Z-Order essentially preserved when a new Child opens.  As the Child opens, the Parent loses the focus; at that point I'd like the Parent to drop back to its former position in the Z-order.  I could add requirements along this line, but you get the idea ... I imagined a default behavior might do what I want, but if I have to assign Z-order locations from an array or something like that, I could accept that. </p>
  
  <p>I also want to control the on-screen position of the Child forms (I mean only when they are first opened; they can be repositioned).  If they open with the same <code>X,Y</code> coordinates, they'll appear stacked on top of each other and the user will have to reposition the top instance in order to see the others.  That is inconvenient and, more important I think, disorienting. </p>
  
  <p>So far I'm not able to have it all.  I can get a nice cascade result by specifying <code>X,Y</code> positions, but it stops working when I use the flags to poke at the Z-order.</p>
  
  <p>I've been using the API...</p>
  
  <pre><code>Declare Sub SetWindowPos Lib "user32" ( _
                  ByVal Hwnd&amp;, _
                  ByVal hWndInsertAfter&amp;, _
                  ByVal X&amp;, ByVal Y&amp;, ByVal cX&amp;, _
                  ByVal cY&amp;, ByVal wFlags&amp;)
  
  Global Const HWND_TOP = 0
  Global Const HWND_TOPMOST = -1
  
  SetWindowPos Hwnd, HWND_TOP, lngPosX, lngPosX, 0, 0, SWP_NOSIZE
  </code></pre>
  
  <p>I have different results when I try options for <code>hWndInsertAfter&amp;</code> and <code>wFlags&amp;</code>.  Also when I set forms as <code>Popup</code> (results are better, but as mentioned, I want the user to bring any form to the top; therefore no <code>Popup</code>).</p>
  
  <p>(Hmm... I bet <code>Popup</code> (and 'Modal`) are precisely what bring the API into best usage, because while a "must-answer" dialog is showing, control basically reverts to Windows.  Confirm?)</p>
  
  <p>My biggest frustration is that documentation for the API seems fragmentary and incoherent.  And I wonder, <em>am I stuck with that API?  Is there something else I can use?</em>  I'd love a VBA solution apart from the API, but I guess this is what the API is for.  Still, is there a method I'm missing?</p>
  
  <p>I can post my variant attempts in more detail, but I feel I've been shooting in the dark, so I will wait on your feedback.</p>
  
  <h2>Update</h2>
  
  <p>I tried Reading <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545%28v=vs.85%29.aspx" rel="nofollow noreferrer">The Manual</a>.  I tried twiddling with "form ownership" and <code>NO/TOPMOST</code>.  For the Child form, <strong>I still have to choose between:</strong></p>
  
  <ol>
  <li>Being able to set the position upon opening</li>
  <li>Being able to bring the Parent form back "on top" of the Child</li>
  </ol>