title: Pass data between UserForms
body: <p>Within Excel VBA I have a User Form similar to the following where the user enters an ID number and then the details are displayed on the user form:</p>
  
  <pre><code>Private Sub btnIDNo_Click()
  Dim IDNo As Long
  If txtIDNo.Text &lt;&gt; "" Then
      If IsNumeric(txtIDNo.Text) = True Then
          lblError.Caption = ""
          IDNo = txtIDNo.Text
          Worksheets("Details").Activate
          Range("B4").Select
          While ActiveCell.Value &lt;&gt; "" And ActiveCell.Value &lt;&gt; IDNo
              ActiveCell.Offset(1, 0).Select
          Wend
          If ActiveCell.Value = IDNo Then
              txtName.Value = ActiveCell.Offset(0, 1).Value
              txtPhone.Value = ActiveCell.Offset(0, 2).Value
          Else
              lblError.Caption = "Cannot find ID nummber"
          End If
      Else
          lblError.Caption = "Please enter the ID Number in numeric form"
      End If
  End If
  End Sub
  </code></pre>
  
  <p>On the Details User Form, I have an "Edit" button. Clicking the "Edit" button would open another user form where the user can change the details of that ID number, but obviously not the ID number itself. To do this, I need to pass the ID number from the Details User Form to the Edit User Form. Is there a way of doing this?</p>
  
  <p>The bottom on the Show Details User Form to open the Edit User Form is similar to the following:</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  Dim IDNo As Long
  If txtIDNo.Text &lt;&gt; "" Then
      If IsNumeric(txtIDNo.Text) = True Then
          lblError.Caption = ""
          IDNo= txtIDNo.Text
          ufmEditDetails.Show
          ufmShowDetails.Hide
      Else
          lblError.Caption = "Please enter the ID Number in numeric form"
      End If
  Range("B4").Select
  End If
  End Sub
  </code></pre>
  
  <p>I have already looked at the following links but they don't seem to help:</p>
  
  <p><a href="http://www.mrexcel.com/forum/excel-questions/671964-visual-basic-applications-pass-variables-between-user-forms.html" rel="nofollow">http://www.mrexcel.com/forum/excel-questions/671964-visual-basic-applications-pass-variables-between-user-forms.html</a></p>
  
  <p><a href="http://gregmaxey.mvps.org/word_tip_pages/userform_pass_data.html" rel="nofollow">http://gregmaxey.mvps.org/word_tip_pages/userform_pass_data.html</a></p>
  
  <p><a href="http://peltiertech.com/Excel/PropertyProcedures.html" rel="nofollow">http://peltiertech.com/Excel/PropertyProcedures.html</a></p>