title: Access Report won't allow me to refer to a field in VBA unless it's on the report in its own right
body: <p>So, in an Access Form or Report a good way to show something dynamic on the screen that is more complex than <code>=[UnitPrice]*[Quantity]</code> is to drop into VBA.</p>
  
  <p>e.g. in this simplified example, the underlying table for this Report has two fields <strong>ShowTax</strong> and <strong>TaxRate</strong>. By making a TextBox's control source <code>=GetTaxInfo</code> I get to introduce some complexity in VBA:</p>
  
  <pre><code>Public Function GetTaxInfo() As String
  
      Dim result As String
      If Me!ShowTax = 0 Then
          result = "Tax included @ " &amp; Me!TaxRate
  
      Else
          result = ""
      End If
  
      GetTaxInfo = result
  
  End Function
  </code></pre>
  
  <p>OK, this works ... so long as I have a field somewhere else that refers to TaxRate. Otherwise it just prints <code>#Error</code>. It's as if it needs to <em>preload</em> the field before it can be used in VBA code. It isn't the end of the world because I can have a bunch of fields in the report all set to not be visible, but it's untidy.</p>
  
  <p>So is it the case that you can't refer to a field <em>in VBA code backing a report</em> unless you have <em>already referred to the field in the conventional way as a field baked into the report?</em> </p>
  
  <p>I can't remember encountering this limitation before. Or is it that I have a corrupt report? (I have tried the usual compact/repair, export/reimport the Report etc)</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>the weird thing is ... now it's working again. And - I'm pretty sure - there is no control in the report. which is why I was thinking it was a corruption in the report. </p>