Y'all, I'm about to go completely insane. I'm a perfectionist and I cannot figure out why the Security Warning: "Do you want to make this file a Trusted Document?" doesn't trigger until I try to close my database, causing a "You can't exit [DB] now" error. The database is located on a Network Share Drive and it is designed to detect whether it's local or not and then prompt the user to save a local copy, open that local copy, and close itself.
The problem is that it throws a very bad looking error when it tries to close. It doesn't matter if I use a Macro or VBA, embedded or standalone, both generate the same error. If I close the form or database manually, the Security Warning ("Do you want to make this a Trusted Document?") finally triggers, but the error isn't generated.
I'm running: Microsoft 365 Apps for enterprise Version 2401 (Build 17231.2090 Click-to-Run)
My Goal
Either trigger the Security Warning on load, or detect the Security Warning and halt execution until it's acted on.
What happens next
Impact: Fundamentally, this is a minor error that goes away entirely once users properly move the database to a local drive. However, it is driving me insane because it's so inexplicable and also the first touch on my DB my users will have.
What I've Tried So Far
None of these have changed the error.
Database Structure
Forms:
- Warn Not Trusted (default)
- Warn On Network
- Admin Options
Macros:
- AutoExec:
- If [isTrusted], close "Warn Not Trusted"
- If vbaDriveType <> "Local", show "Warn On Network"
- Else, UpdateMainDB, then LaunchMainDB
VBA:
- UpdateMainDB/LaunchMainDB: Checks version, then either updates or launches main DB.
- Utilities: vbaDriveType: If .Path like C:\*, then Local
Limitations
Did I miss something obvious? Am I SOL? Did I stumble upon a genuine bug?
For my steadily dwindling sanity, I beg y'all for help!
Stumbled upon the answer: Using a Macro to open a form as a Dialog suspends execution until the form is closed, regardless of whether there is any further code/macro to execute. See remarks here: https://support.microsoft.com/en-us/office/openform-macro-action-8ece67cc-783c-4b2e-9f33-0e24e8436a05
Solution: Open the form as Normal, with Modal and Popup set to "Yes".
I hadn't included that detail in my initial question as I didn't recognize it as important. I may not get my 9 hours back, but maybe someone else can avoid this dumb fate.