Allow Code To Run . .

Evagrius

Registered User.
Local time
Today, 02:42
Joined
Jul 10, 2010
Messages
170
Hi all,

I would like to find a simple way to help my users enable their macros. I currently have a database that displays a form as soon as the database is opened. The issue is the form will not work unless Macros are enabled.

I would like to have a form with instructions on how to enable macros. Once the user open the database, if macros are enabled, the form with the instructions will be set to hide, and the regular form will be made visible.

In Excel there is a "Workbook" open event, is there such a thing in Access? Also, how can I prevent the user from accessing the Access optoins and changing the "Display Form" field? Thank you for any examples or help.
 
If you download the Access 2007 Northwind Database example, you will see how they do it. They have two forms and then an autoExec macro. If the database is opened and a trusted location is not set, it will display the one form which has instructions on it (and no code or macros on it). If the location is trusted it will use the normal opening form.

See if that helps.
 
Hi Bob - thank you for your help.

I think I am almost there but not quite. I followed the example of Northwind as you suggested. When I open the database, however, no form opens. This is the first macro I've created so I am not sure what I am doing wrong.

In the NorthWind Macro, I noticed that in the first row of the Macro, they have the Action "Set Displayed Categories." Under arguement they have "YES" and the name of the Database.

I have the yes there as well, but I couldn't figure how to place the name of my database. Could this be why it is not working? If I click on the macro - the appropriate forms opens - in other words, If I click on the macro and I have not yet enabled content - the directions appear - I just have to make sure it opens automatically now. Than you Bob.
 
Hi Bob - thank you for your help.

I think I am almost there but not quite. I followed the example of Northwind as you suggested. When I open the database, however, no form opens. This is the first macro I've created so I am not sure what I am doing wrong.

In the NorthWind Macro, I noticed that in the first row of the Macro, they have the Action "Set Displayed Categories." Under arguement they have "YES" and the name of the Database.

I have the yes there as well, but I couldn't figure how to place the name of my database. Could this be why it is not working? If I click on the macro - the appropriate forms opens - in other words, If I click on the macro and I have not yet enabled content - the directions appear - I just have to make sure it opens automatically now. Than you Bob.
More importantly what do you have for the 2nd and 3rd rows of the macro? The [IsTrusted] part is the key. And the instructions form CANNOT have any macros or code on that form at all or it will fail.
 
Forget the first line, that setups up the navigation pane.

The second line tells what form to open if the location of the db is not trusted which opens the form to instruct the user how to enable the code and macros in the database.
 
Ghudson - I found these instructions on the web for 2007 Northwind.




1. Open Access
2. On the Getting Started screen there are some categories listed in the
left task pane
3. Click the one called Sample
4. You should see the Northwind 2007 template now in the middle of the
screen
5. Click on the icon, enter the name and location on the right task pane,
and then click the Download button Try this (assuming you're using Access 2007):
1. Open Access
2. On the Getting Started screen there are some categories listed in the
left task pane
3. Click the one called Sample
4. You should see the Northwind 2007 template now in the middle of the
screen
5. Click on the icon, enter the name and location on the right task pane,
and then click the Download button
 
Where is the Access 2007 Tutorial: Northwind Traders Sample Database? I can only find 2000 and 97 http://www.microsoft.com/downloads/...ia=Popularity&sortOrder=Ascending&stype=s_adv

Edit:
Dang, it was already on my pc @ C:\Program Files\Microsoft Office\Templates\1033\Access\Northwind.accdt as a template file.

Actually, in 2007 when you are on the main screen, you can create a new database from that template by choosing the local ones on your computer - Northwind is listed as one of them. Just like in 2003 you can get to it without looking by going to HELP > SAMPLE DATABASES.
 
Actually, in 2007 when you are on the main screen, you can create a new database from that template by choosing the local ones on your computer - Northwind is listed as one of them. Just like in 2003 you can get to it without looking by going to HELP > SAMPLE DATABASES.

Thanks. I admit I have not viewed an Access template since Access 97.
 
Hi Bob - it seems to work now. I didn't know HAD that I had to name the macro AUTOEXEC and no other name.

Bob - what do you recommend in preventing the user from displaying the navigation pane? I don't want the user to be able to view anything other then the form. Thank you for already helping me considerably Bob!
 
Hide the window and the ribbon...

Code:
DoCmd.RunCommand acCmdWindowHide
DoCmd.ShowToolbar "Ribbon", acToolbarNo

It will still open with the F11 key until you deselect the Use Access Special Keys option.
 
To keep the Nav Pane away...

1. Do a search here for DISABLE BYPASS KEY and find the code which keeps you from holding shift down while opening the database.

2. Then go to the Round Office Button, Access Options and then find, under the CURRENT DATABASE selection - USE ACCESS SPECIAL KEYS and uncheck the box. That will keep them from hitting F11 and getting it.

And then just do your development and when ready to release -

ON A COPY of your master file, run the Disable Bypass Key code and go uncheck that box. If you leave it checked then you can use breakpoints and all but if you uncheck it, it will not stop at a breakpoint during testing.
 
And also you might need to go into the Current Database area (as noted above) and uncheck the Allow Default Menus so the Access Options won't show up.
 
Thank you so much Bob - I will follow your steps and see how that works!

Ghudson - I am still learning so this is a stupid question - where does the code you posted go? I mean - what event makes it run? Thank you!
 
One method is to put it in the On Open event of the first form that is opened when the db is first opened.
 

Users who are viewing this thread

Back
Top Bottom