title: Assigning a string to a variable in Access VBA
body: <p>I'm trying to assign the name of a field in a loop to a specific variable in access vba. Then I need this variable to read a specific record from the database. Below you have the piece of code:</p>
  
  <pre><code>For n = 0 To numfields - 1
          a = "!" &amp; rst.Fields(n).Name
          If IsNull(!Field1) = False Then
              If n = 1 Then strOutput = strOutput &amp; a
              If n &lt;&gt; 1 And n &lt;&gt; 0 Then strOutput = strOutput &amp; ";" &amp; "!Field" &amp; n
          End If
      Next n
  </code></pre>
  
  <p>The problem is the following: the stored value in the variable would be "!Field(n)" in text and will not get the value from the database in my conditional statement since it's not reading it. Is there any way to convert this text to and actual !Field(n) variable that can read from the database?</p>
  
  <p>Thank you for your help.</p>