title: set value for other userform controls on userform close
body: <p>really struggling with this one, found a solution for the time being but it's not really a satisfactory one.
  I have a workbook with two user forms, one to input data and one to search for previously entered data and a third user form designed as a date picker form which is set to activate on entry of a designated date text box. </p>
  
  <p>Individually I have no problem, the user clicks the text box and the date picker form appears, they make their selection which closes the date picker form and adds the date to the text box. On the "input data" form I have a multi page with a single date selection text box on each of the two pages, on the "find data" form I have an option to search a single date or a range, 3 date selection text boxes in total.</p>
  
  <p>now I am noticing that userform1 (input data) is prompting a run time error 91 - object variable or With block variable not set and is flagging the first line for userform2 in the code whenever I select a date from the date picker form.</p>
  
  <p>what I did notice however was that the correct date was still being entered into the textbox so as a fix I added an 'On error goto' line above the highlighted line which is allowing the action to take place without interruption. What I did notice was that now if I enter a date anywhere on userform2 (find data) and then close the form and decide I want to enter data instead, the text box on userform1 will contain whatever the previous selection was on userform2. What is especially puzzlng about this to me is that the initialize event for UF1 enters the current date in the date text box.</p>
  
  <p>see code below, is there a much better way to write this? I hope I explained well enough, please let me know if I can provide additional details to help.</p>
  
  <pre><code>Sub CloseDatePicker(save As Boolean)
  
    If UserForm1.MultiPage1.Value = 0 Then
    UserForm1.tbDate.Text = Calendar1.Value
    UserForm1.cbMember.SetFocus
    ElseIf UserForm1.MultiPage1.Value = 1 Then
    UserForm1.tbDate2.Text = Calendar1.Value
    UserForm1.cbMember2.SetFocus
   End If
  
   On Error GoTo dpexit
  
  If UserForm2.ActiveControl.Name = "TextBox1" Then
  UserForm2.TextBox1.Text = Calendar1.Value
  End If
   If UserForm2.ActiveControl.Name = "TextBox2" Then
   UserForm2.TextBox2.Text = Calendar1.Value
   ElseIf UserForm2.ActiveControl.Name = "TextBox3" Then
   UserForm2.TextBox3.Text = Calendar1.Value
   End If
  
  dpexit:
      Me.Hide
  End Sub
  </code></pre>