title: How to get count of db recordsets/references (to debug err #3048 - can't open more databases)?
body: <p>I started getting error 3048 - Can't open more databases.
  I seem to have tamed it by implementing a single, static database variable
  in a function "dbLocal()" after <a href="https://stackoverflow.com/questions/1833746/ms-access-is-there-a-significant-overhead-when-using-currentdb-as-opposed-to-db">David Fenton's example here</a>.</p>
  
  <p>I would still like to monitor the number of database references to see how close I am getting to the 2048 limit in Access. I have tried to use .Recordsets.Count but it always returns zero. How can I determine the reference/recordset count being used internally by Access?</p>
  
  <p>One place I've tried to look at it is in the "dbLocal()" function. Stripped down to less-than-bare-minimum here (in my code I use Fenton's full example), I'm trying this:</p>
  
  <pre><code>Public Function dbLocal() As DAO.Database
  
      Static dbCurrent As DAO.Database
  
      If dbCurrent Is Nothing Then
          Set dbCurrent = CurrentDb()
      End If
      Set CurDb = dbCurrent
      Debug.Print dbCurrent.Recordsets.Count
  
  End Function
  </code></pre>
  
  <p>but it always prints zero. Even if it worked, it's not what I really want, because (if I am understanding correctly) Access is maintaining its own accounting that includes references due to queries, combo-boxes, etc., whereas my static variable would only "know about" references due to VBA statements explicitly using this dbLocal() function.</p>
  
  <p>Is there a way to get a peek at Access' internal accounting to know how close I might be to exhausting the 2048 maximum?</p>
  
  <p>In case it matters: Windows XP Pro SP3; Access 2010 32-bit version 14.0.6024.1000 SP1 MSO 14.0.6112.5000.</p>