English 中文(简体)
How to force user to deal with the Security Warning when starting Access 2007?
原标题:

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"
最佳回答

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!

问题回答

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

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

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.

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.

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!





相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签