title: Access parent and other open forms from a subform
body: <p>In continuation to my application development, I have encountered another intersting problem. </p>
  
  <p>In my MS Access application, I am using a form which contains only two controls - a textbox and a command button. This form is named as <code>HEADER FORM</code>. </p>
  
  <p><code>HEADER FORM</code> is used as a subform in header section of various other forms. </p>
  
  <p>Figure below shows the subform and its use in one of the main form. </p>
  
  <p><img src="https://i.stack.imgur.com/QJ5c2.png" alt="enter image description here"></p>
  
  <p>Now, what I want is that when user clicks on Logout button of the subform, the logout action shall happen (which is fine and I am able to figure it out) and all the forms that are open at that point in time shall be closed / unloaded. </p>
  
  <p>I tried using following code to no avail. </p>
  
  <pre><code>Option Compare Database
  
  Private Sub cmdHeaderLogout_Click()
      If (loggedIn = 1) Then
          loggedIn = 0
          DoCmd.Close acForm, Parent.Form
      End If
  End Sub
  </code></pre>
  
  <p>When I try to click on logout button, control reaches DoCmd.Close statement above. And execution stops after giving following error message: </p>
  
  <blockquote>
    <p>Run-time error: 2498. An expression you entered is the wrong data type
    for one of the arguments.</p>
  </blockquote>
  
  <p>and it points to <code>Parent.Form</code> text.</p>
  
  <p>I am not able to figure out how to refer to parent form and unload the same?</p>