title: Reference Parent property
body: <p>I have a form that in certain situations doesn't have a parent.<br />
  Then it fails to open.<br />
  So I wrap it in an 'if'<br />
  It still fails to open.</p>
  <pre><code>Private Sub Form_Open(Cancel As Integer)
      If Not Parent Is Nothing Then  &lt;&lt; Error
          Me!Button1.Enabled = Not (Nz(Parent!Lock, 0))
          Me!Button2.Enabled = Not (Nz(Parent!Lock, 0))
      End If
  End Sub
  </code></pre>
  <p>gives &quot;Run-time error '2452': The expression you entered has an invalid reference to the Parent property.&quot;<br />
  But if I declare the variable, then the original code won't work.</p>