title: Update value in another form's textbox via VBA
body: <p>Hopefully this makes sense. I'm frustrated that I cannot figure this out. I have a simple Access 2010 database. I have a simple form inside it that helps the user input some specific information. This data entry situation can occur on two other forms in the database. Rather than have two copies of the "helper" form where the VBA code has hard-coded control references, I wanted to make it more universal by passing the name of the form that calls it by using the openArgs parameter.</p>
  
  <p>When the time comes to transfer the values BACK to the form that needs the information, the helper form attempts to do this like so:</p>
  
  <pre><code>Private Sub cmdOk_Click()
      Dim theFormName As String
      Dim theForm As Form
  
      theFormName = Me.OpenArgs
      Set theForm = Forms.Item(theFormName)
  
      If Not IsNull(theForm.Name) Then
          theForm.txtLongitude.Value = Me.lblLongitude.Caption
          theForm.txtLatitude.Value = Me.lblLatitude.Caption
      End If
  
      DoCmd.Close acForm, Me.Name, acSaveNo
  End Sub
  </code></pre>
  
  <p>The variable <code>theForm</code> is populated correctly and <code>theForm.Name</code> returns the correct name of the form so that part works fine. The problem is that <code>theForm.&lt;controlName&gt;.Value</code> does not. When I run the code, I get an </p>
  
  <blockquote>
    <p>application-defined or object-defined error (Run-time Error 2465)</p>
  </blockquote>
  
  <p>I've tried all sorts of permutations for the control reference from the current open form to a second open form but I cannot get the syntax right. I've tried:</p>
  
  <pre><code>theForm!txtLongitude.Value ("..can't find the field txtLongitude..")
  theForm.Controls("txtLongitude").Value ("..cant find the field...")
  </code></pre>