title: Access Filter VBA
body: <p>I'm trying to use a filter in vba like this:</p>
  
  <pre><code>Private Sub Form_Load()
  
      Me.Filter = "[Alvo] = " &amp; AlvoAtual  
      Me.FilterOn = True  
      Me.Requery  
  
  End Sub
  </code></pre>
  
  <p>Where AlvoAtual is global variable, but nothin happens. When I change the AlvoAtual for a specifc value nothin happens too. Like this:</p>
  
  <pre><code>Private Sub Form_Load()
  
       Me.Filter = "[Alvo] = 'AAAA'"
       Me.FilterOn = True
       Me.Requery
  
  End Sub
  </code></pre>
  
  <p>Someone knows the problem?</p>
  
  <hr>
  
  <p>I am adopting this question (VBAWhatnow) in the hope of it getting answered rather than make a duplicate as I was <a href="https://meta.stackexchange.com/questions/136208/if-my-question-is-a-duplicate-but-there-is-no-answer-to-the-original-question-w#comment380451_136208">advised</a>.</p>
  
  <p>I am trying to do the same thing except with local variables.</p>
  
  <p>My filter works correctly when I manually define the values but when I introduce the variables the filter no longer works</p>
  
  <pre><code>Forms![frmPendingActions]![qryPendingAction subform].Form.Filter = "Filterby = FilterCrit"
  </code></pre>
  
  <p>Could anyone help me find a good solution?</p>