How to Determine if your Solution is in Disabled Mode
I was asked this question the other day and thought it's worth answering right away, and in public': "How can I programmatically determine that my solution is in disabled mode in Access 2007?"
Well, this is very simple: by checking the value of the IsTrusted property off of the CurrentProject object. If it is set to true, the solution is enabled. If it is false, it is in disabled mode.
Notice that you can use this in a simple standalone or embedded macro to determine if you want to try to run some VBA code or not. For example, in this macro you can simply tell the user to enable the solution:
Condition Action Arguments
Not [CurrentProject].[IsTrusted] MsgBox "Trust my solution before using!"
Not [CurrentProject].[IsTrusted] CloseDatabase
[CurrentProject].[IsTrusted] RunCode VBAStartup
9/19: Fixed typo "[CurrentProject.IsTrusted]" to "[CurrentProject].[IsTrusted]". Thanks for catching it, Andre.
Comments
- Anonymous
September 19, 2006
Access was not able to interprete [CurrentProject.IsTrusted], but [CurrentProject].[IsTrusted]. Maybe [CurrentProject.IsTrusted] only works with the English version (I use the German one)? - Anonymous
September 19, 2006
Oops, but that was actually a typo. I'll fix the post - [CurrentProject].[IsTrusted] is the right syntax. Thanks for catching it. - Anonymous
October 05, 2006
Now that Access 2007 Beta 2 Technical Refresh (B2TR) is out, you will notice that we changed the Switchboard