title: How to manage references on Access 2010 and Access 2016 in the same database
body: <p>I have an Access Database working with Access 2010 and 2016. 
  So, If is firstly opened with 2016, when a user open it with 2010, a reference error trying to access to Excel library (Microsoft Excel 16.0 Object Library) occurs. To solve it I need to change manually the reference to 14.0 one in the reference menu.</p>
  
  <p>I'm trying to do this programatically in VBA, checking the version of Access, if version is 2010 (14.0) I need to delete Microsoft Excel 16.0 Object Library and add 14.0 instead. When is 2016 I think I dont need to do anything.</p>
  
  <p>trying two options:</p>
  
  <ol>
  <li>With Precompiling Code and directives:</li>
  </ol>
  
  <blockquote>
  <pre><code>#Const ver = Application.version
  #If ver = "14.0" Then
      Call References.AddFromFile("C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.exe")
  #End If
  #If ver = "16.0" Then
      'Call References.AddFromFile("C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.exe")
  #End If
  </code></pre>
  </blockquote>
  
  <p>My problem here, checking documentation, is that i'm not totally sure if I can check access version in precompiling time.</p>
  
  <ol start="2">
  <li>In my initial form open method</li>
  </ol>
  
  <blockquote>
  <pre><code>If Dir("C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.exe") &lt;&gt; "" And Not refExists("excel") Then
      Access.References.AddFromFile ("C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.exe")
  End If
  If Dir("C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.exe") &lt;&gt; "" And Not refExists("excel") Then
      'Access.References.AddFromFile ("C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.exe")
  End If
  If Dir("C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.exe") = "" And Dir("C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.exe") = "" Then
      MsgBox ("ERROR: Excel not found")                                  
  End If
  
  Private Function refExists(naam As String)
  Dim ref As Reference
  refExists = False
  For Each ref In References
      If ref.Name = naam Then
          refExists = True
      End If
  Next
  End Function
  </code></pre>
  </blockquote>
  
  <p>In this time, my initial form have many internal references and some of them takes Excel library. When I try to do this, the error occurs after executing the code.</p>
  
  <p>Does anyone knows what can I do to solve this problem? I hope my code help you understand the problem.</p>
  
  <p>Thanks!</p>