I am trying the following code but it is referencing not the last but the one befor that. I have a calander on a userform along with sereval textboxes. I want to clik on the textbox and then click the calander to fill in the daye to that checkbox.

Right now this code is doing the one before. For example, if I click ib textbox2 and then texbox3 and then click the calander it is putting the date in textbox2.


Private Sub Calendar1_Click()
    If Not m_ctlPreviousControl Is Nothing Then
        m_ctlPreviousControl = Calendar1
    End If
End Sub

Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set m_ctlPreviousControl = Textbox1
End Sub
Private Sub Textbox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set m_ctlPreviousControl = Textbox2
End Sub
Private Sub Textbox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Set m_ctlPreviousControl = Textbox3
End Sub