Search code examples
vbaformsms-accessunsafe

MS Access form gets broken after enabling unsafe content


I have a MS Access project, which was developed in MS Access 97. I successfully converted it to MS Access 2016 (that was a long story tho). Everything looks fine, but I have noticed a very strange behavior.

When user opens the project file in client mode for the first time, a lot of macro errors pop up. This is a normal thing, because user has not yet allowed unsafe content in this file. So, after user has closed all the errors, he presses "Allow unsafe content" button and closes the file. Now user opens the project again and it is not working properly. Some forms are invoked that should'nt be invoked and "Module not found" error pops up. I didn't develop any modules for this program. So, it means that if user opens the file without allowing unsafe content first, the project gets totally messed up and it's impossible to recover unless you replace the file with a fresh copy.

However, if user has a fresh copy of project .accdb file, and the file is located in trusted location, everything works fine. Another way to make project run properly without putting it to trusted location is to open it while holding shift key first and pressing "Allow unsafe content" button. Then user can normally run file with double-click and it works like it should.

So, opening this file without allowing unsafe content first breaks the project. I've also tried to open VBA code of the form, which is invoked by default and the VBA code windows looks frozen. Other forms are working fine. enter image description here

How can I debug this problem?

UPD: It really looks like the problem is caused by attempting to run macros while unsafe content is not enabled.

UPD: I noticed one more thing - if I run the project without allowing unsafe content first, but I don't press "allow content", and just close the program - I'm still able to run it from trusted location. So the corruption happens only after I press "enable content" button. My form has macro with OnClose action attached. But I tried to remove all the macros from this form and it didn't help.


Solution

  • I've ran into some more weird problems and while debugging them found out that there are some MS Office 2000 footprints on the system. I decided to uninstall MS Office, clean Windows registry and install MS Office again. This solved all my problems.