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

夙愿已清 提交于 2020-08-10 06:05:14

问题


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

回答1:


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"


来源:https://stackoverflow.com/questions/32822374/how-do-i-allow-databases-to-run-activex-content-when-opened-with-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!