title: Getting record count of subform when filtered using acCmdFilterMenu
body: <p>I'm wanting to get a record count of my subform each time it is filtered in some way. The text box containing the record count value will be held on the main form.</p>
  
  <p>The record count method I'm familiar with is:</p>
  
  <p><code>Trim([FORM/SUBFORM ADDRESS].RecordsetClone.RecordCount)</code></p>
  
  <p>This works fine where the subform is being filtered by changes to Record Source's SQL via VBA. </p>
  
  <p>More recently though I've added the ability for the user to also filter on the subform columns using command buttons running <code>acCmdFilterMenu</code>, i.e. these type of menus:</p>
  
  <p><img src="https://i.stack.imgur.com/rJa9l.jpg" alt="acCmdFilterMenu type menus"></p>
  
  <p>I've put the record count method in a module so it could be called globally between form and subform events:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public Sub InboxCount()
  
      Forms!Home.txtInboxCount = Trim(Forms!Home!tblJob_Search_sub.Form.RecordsetClone.RecordCount)
  
  End Sub
  </code></pre>
  
  <p>I'm then calling the record count in the subform's OnApplyFilter event:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
  
      MsgBox "Filter Applied"
  
      InboxCount
  
  End Sub
  </code></pre>
  
  <p>The test message "Filter Applied" fires so it is running the code in that event, it just seems that the record count method I'm using doesn't work when the subform is filtered using <code>acCmdFilterMenu</code>... it does work when I filter the subform using commands that change the Record Source's SQL though.</p>
  
  <p>How might I get the subform's record count when the subform is filtered using <code>acCmdFilterMenu</code>?</p>