title: How to reference control names dynamically in MS Access
body: <p>I have the following code in an MS Access Form object. </p>
  
  <pre><code>Private Sub UpdatePMText(sLang As String)
  'Used to pass both Mandate and Language Info to called Sub that will execute the queries
  Dim iMandate As Integer
  
  'Check if there is text in the box.
  If Me.Controls("txtInput_PM_" &amp; sLang &amp; "_DRAFT") = Null Or Me.Controls("txtInput_PM_" &amp; sLang &amp; "_DRAFT") = "" Then
      MsgBox ("There is no text in the " &amp; sLang &amp; " DRAFT Field." &amp; vbNewLine &amp; "The operation will not be executed.")
      Exit Sub
  End If
  
  iMandate = Me.txtMandateID
  Call modUpdateText.macro_PMText(iMandate, sLang)
  
  End Sub
  </code></pre>
  
  <p>If I refer to the Controls directly and simply type out the names of the forms, for example <code>txtInput_PM_EN_DRAFT</code> then the code works as intended.</p>
  
  <p>The error message I get is that Access can't find the "Field" I'm referring to when I am on the first <code>IF</code> statement line. I have tried changing the <code>.Controls</code> to <code>.Fields</code> but that didn't work either.</p>
  
  <p>I do not want to repeat the same code for every language I need to run. How do I reference control names dynamically in MS Access? What am I missing?</p>