title: Access: Refer to text box from detail section of subreport from main report
body: <p>I can successfully refer to the value in a text box in the subreport <em>footer</em> using <code>[subreportName].[Report].[textBoxName]</code>. However, I would like to refer to a text box in the <em>detail</em> section. Using the above just gives the last value it contained - I would like to refer to a specific one (by field, say).</p>
  
  <p>Is this possible, or is there some workaround? </p>
  
  <hr>
  
  <p>Update: This is what I have so far. <code>fieldA</code> is the name of the text box that I want to use to pick out the correct entry (the correct entry will have "keyString" in this text box), and <code>fieldB</code> contains the value I want to actually store.</p>
  
  <p>In the <code>OnFormat</code> event in the subreport detail section:</p>
  
  <pre><code>Dim varToStore As Double
  Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
      If Me![fieldA] = "keyString" Then
          varToStore = Me![fieldB]
      End If
  End Sub
  </code></pre>
  
  <p>In a new Module:</p>
  
  <pre><code>Function getVariable(Name As String)
      If Name = "varToStore" Then
          getVariable = varToStore
      Else
          getVariable = -1
      End If
  End Function
  </code></pre>
  
  <p>In the Control Source of the text box in the main report:</p>
  
  <pre><code>=getVariable("varToStore")
  </code></pre>
  
  <p>I'm using the general function getVariable since there are a few variables from the detail section that I'm planning to store, so I thought it would be easier to just pass arguments to one function, rather than having a function for each.</p>