How to force user to deal with the Security Warning when starting Access 2007?

落爺英雄遲暮 提交于 2019-12-04 04:18:53

问题


When a user start an Access 2007 database that have macros and vba, a security warning is shown. I want the user to deal with this warning, so if the the content is't enabled, the user should not be able to use the database.

Now I use a macro named AutoExec (opens a form that works like a menu), and that macro is run before the user deal with the security warning. But I want to check if the content is enabled and if not I will show a form that inform the user that they should enable the content.

So what I'm actually asking for is how do I do this:

  1. If vba and macros is not enabled -> show form "information"
  2. If vba and macros is enabled -> show form "start menu"

回答1:


Ok, after a while I have the solution. Thanks for the answers who led me the right way.

This article from Microsoft is very helpful.

In the AutoExec-macro, I have two lines:

Line one: Conditions: [CurrentProject].[IsTrusted]=False and then I choose witch Form I want to open and in this case it is the "info about security warning form"

Line two: Conditions: [CurrentProject].[IsTrusted]=True and now open the "start menu form"

And that's all!




回答2:


If the content is disabled, then you cannot check, since your code cannot run....




回答3:


You might like to consider a start-up form ("information"). This will show without macros.

In addition, you can run some start-up code or a macro that closes the information form and opens the main form ("start menu"), if macros are disallowed, this will not run. However, I think you may get an unsightly warning.

EDIT

Set the timer interval to say, 100 and add a little code to Information form:

Private Sub Form_Timer()
   DoCmd.Close acForm, "Information"
   DoCmd.OpenForm "start menu"    
End Sub



回答4:


Just to add my solution -- I was just dealing with this issue.

By default, in database options have it set to open with form "notEnabled" On this "not enabled" form, have some text, pictures, or what have you that lets the user know that he/she needs to 'enable content'.

In the on load event for this form, just put some VBA to open the actual form you want the user to be presented and close the "notEnabled" form.

This way, if the user opens the database without making it trusted, enabling content, they are stuck on the form that tells them how to do that. As SOON as it's trusted, the on-load event of the form will fire and redirect the user to whichever form you want, with content enabled.

If the user opens the database and already has trusted the file, they don't see the form telling them to make it trusted.




回答5:


You can avoid this by setting the IsTrusted flag to TRUE in your AutoExec macro. See Transitioning Your Existing Access Applications to Access 2007 -- search for IsTrusted to get you to the heart of the explanation of how to handle it.




回答6:


I don't know why people give suggestions that have not been tested yet. My solution is simple:

If: [CurrentProject].[IsTrusted]=False RunMenuCommand: CloseDatabase

Else

If: [CurrentProject].[IsTrusted]=True RunCode: (you run the code or macro you wanted to in the first place here)

This basically closes the database if the security warnings are coming on. If they are not, it opens just fine. The user that is the admin will need to decrease the macro security levels on the computer of whoever wants to access the database. This macro unlike others will actually run because it agrees with what Access wants.

You're Welcome!



来源:https://stackoverflow.com/questions/1852215/how-to-force-user-to-deal-with-the-security-warning-when-starting-access-2007

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