Search code examples
securityms-accessvbams-access-2013trust

How do I allow databases to run activex content when opened with VBA?


In Access 2013 (64-bit) I'm opening another database (db2) when the user clicks a button on a form in db1. This is working. However, when it opens db2 I get the warning bar "Security warning: Some active content has been disabled. Click for more details" with a button to enable the content. This is annoying and when I open the database from db1 with forms also opened, when I click the button to enable the content all currently open forms are closed.

Both databases are in the same directory, and I have added this directory to the trusted locations. Is there something else I need to do to disable this warning bar without automatically trusting all databases (something I don't want to do)?

When I manually open each database, I don't see the warning bar appear, so I assume it's something to do with the VBA code I'm using:

Dim db2 As Variant
Set db2 = CreateObject("Access.Application")
db2.OpenCurrentDatabase "NewDb.accdb"    
db2.DoCmd.OpenForm "_View"
db2.DoCmd.OpenForm "_Home"
db2.UserControl = True

Solution

  • Include the full path to NewDb.accdb when you call OpenCurrentDatabase. I think you want the same folder as the first database (db1). CurrentProject.Path will give you the full path of that folder ...

    db2.OpenCurrentDatabase CurrentProject.Path & "\NewDb.accdb"