Avoid using References in Access VBA

When I investigated the problem opening the same database in Access 2010 and Access 2013 / 2016  that breaks the DB I came to the conclusion that this is originated by a bug in Access that doesn’t allow the DB to use references to other office applications (in your case Outlook) when downgrading the version.

What is a reference?

When programming in VBA you can add “references” to libraries that will help you in coding, for instance if you want to connect your access VBA to outlook you can add a reference to outlook library.

Adding the library on Access 2010
Ref1

Open the DB on Office 2013 will change the Version of the Office product to 15.0 (Excel, Outlook, PowerPoint)
Ref2

If you open the same DB using Office 2016 – Access will automatically change the version of the library to 16.0
Ref3

For Office 2010 the Outlook Library is 14.0
For Office 2013 the Outlook Library is 15.0
For Office 2016 the Outlook Library is 16.0

That means, going up is not a problem…  but… going down…

If I want to open it again on 2010, Access will not change the version to 14.0, and now the references are Missing!
Ref4

This also happen from 2016 to 2013…
Ref5

Easy fix
Remove those references and add them again.

Permanent Fix
Avoid using references

How?
Use LATE Binding instead of EARLY Binding…  there is a lot of discussion about this topic on internet, I like this one

http://excelmatters.com/2013/09/23/vba-references-and-early-binding-vs-late-binding/

Basically you need to modify a little your code when declaring the variables.

Instead of this code (EARLY BINDING USING REFRENCES)

Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim olConItems As Outlook.Items

Set olApp = New Outlook.Application

Use this code avoiding references (LATE BINDING)

Dim olApp As Object
Dim olNamespace As Object
Dim olFolder As Object
Dim olConItems As Object

Set olApp = CreateObject(“Outlook.Application”)

Hope it helps!

 

Leave a comment