title: A Null Refrence Exception while working with Properties
body: <p>Do you see where the problem lies? Code will run from frmFacility and will shift into UserControl:</p>
  
  <pre><code>Public Class frmFacility
  Private primaryBaseDay As Date
  Private isClassPrimaryView As Boolean = False
  Friend WithEvents BookCtrl As ucBookCtrl2
  Public Property Primary_BaseDay() As Date
      Get
        Return primaryBaseDay
      End Get
      Set(ByVal value As Date)
        primaryBaseDay = value
      End Set
    End Property
  
    Public Property IsOnPrimaryView() As Boolean
      Get
        Return isClassPrimaryView
      End Get
      Set(ByVal value As Boolean)
        isClassPrimaryView = value
      End Set
    End Property
  Public Sub GotoDay(ByVal theDay As Date)
      Primary_BaseDay = theDay
      IsOnPrimaryView = True
      BookCtrl.GotoDay(theDay)
  End Sub
  End Class
  
     Imports frmFacility
  Public Class ucBookCtrl2
  Public Sub GotoDay(ByVal whichDay As Date, Optional ByVal MainFacilityUsed As String = "")
  Dim facilityForm As frmFacility
  If facilityForm.IsOnPrimaryView Then
          moDoBooking.m_BaseDay = facilityForm.Primary_BaseDay
          moDoBooking.m_CurrentDay = whichDay
          ShowDay()
          RaiseEvent ChangeOfDay()
  End Sub
  End Class
  </code></pre>
  
  <p>At the line <code>If facilityForm.IsOnPrimaryView Then</code>, I get a <code>NullReferenceException</code>. Do you know the reason?</p>
  
  <p>Also, I cannot create a new instance of the <code>facilityForm</code>, since I need to work with  its singleton, although when I add a new instance of <code>frmFacility</code>, the <code>IsOnPrimaryMode</code> is set to <code>false</code> while it should be set to <code>true</code> in the <code>gotoday</code> sub from <code>frmFacility</code>.</p>