title: Access 2007 VBA - Report filter doesn't work until report is reloaded
body: <p>I'm using VBA to dynamically load the content of a report, and depending on which report is selected from the control panel form I've built, the report's query might be filtered.</p>
  
  <p>At the beginning of my Report_Open function, I have this:</p>
  
  <pre><code>Private Sub Report_Open(Cancel As Integer)
      Me.Filter = "VIP=True"
      Me.FilterOnLoad = True
  </code></pre>
  
  <p>Now, this was working when I started this project - I had commented out these lines, and when uncommenting them discovered that this doesn't work properly anymore. Instead of the filter being applied when the report is loaded, I have to reload the report for the filter to work - either by switching to print preview and switching back to report view, or by switching to design view and then back to report view (in design view, the selected filter does display in the properties pane).</p>
  
  <p>I am loading the report using command buttons that allow the user to view, export to PDF, or print (opens in print preview). None of these commands cause the report to open with the filter applied - it has to be reloaded.</p>
  
  <p>The commands I'm using to load the report are below for reference:</p>
  
  <pre><code>If (Action = "View") Then
      DoCmd.OpenReport "Test", acViewReport
  ElseIf (Action = "PDF") Then
      DoCmd.OutputTo acOutputReport, "Test", acFormatPDF
  ElseIf (Action = "Print") Then
      DoCmd.OpenReport "Test", acViewPreview
  End If
  </code></pre>
  
  <hr>
  
  <p>Ok, I have no idea why <code>Me.Filter</code> and <code>Me.FilterOnLoad</code> <strong>don't</strong> work, since from everything I have seen on MSDN and elsewhere, it should work. That being said, I figured out that I can use <code>DoCmd.ApplyFilter</code> instead:</p>
  
  <pre><code>'Check if VIP - add filter if necessary
  If (getGlobal(1) = True) Then
      DoCmd.ApplyFilter , "VIP = True"
  End If
  </code></pre>
  
  <p>I'd still like to know why the other way was behaving so oddly, if anyone has any ideas...</p>