views:

100

answers:

4

Hi!

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  A: 

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

Rick Mogstad
But I hope there is some way around this. If I as default show the "information"-form, and can try to run vba and if it works, it will show the "start menu"-form this may be possible. But I need to supress the error the comes up when the vba-function is called from AutoExec.
Johan
+1  A: 

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
Remou
Yes, thats a good idea. But when the user have accepted to run vba/macros I don't want to show the "information"-form anymore. Instead the "startmenu"-form should be showed. Any ideas?
Johan
That is exactly what I tried. And yes, I get a warning. If I can get rid of the warning, the problem is solved.
Johan
You can add a timer event to information.
Remou
You are not going to be able to suppress the warning, or the people who write the macros it is trying to warn you about would simply suppress it....
Rick Mogstad
I have tested with a timer on a start-up form, and only the standard warning appears, not the unsightly warning that occurs with an autoexec macro.
Remou
+1  A: 

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.

David-W-Fenton
A: 

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!

Johan