Microsoft Access Database: Create a macro that runs when you open an Access database

Microsoft Access Database – AutoExec Macro

Using the AutoExec Macro in Microsoft Access is one of the special reserved macro keyword names that in this case will trigger when you load your database.

It is called before any other macro or VBA code procedure and is used to load forms, resize windows and check settings in your application.

This feature goes way back to the very early days of Microsoft Access and is still popular today with the latest version (2010).

To create an AutoExec macro (using Access 2010) is go to the Create tab, Macro and Code group section and click the large Macro icon.Access Database Macro - AutoExecThere are many different commands with optional arguments & settings that is triggered from a top to bottom order some of which are also logical by nature namely the IF command.

You may need to see all the commands as there are not always visible by going to the Design tab and click the Show All Actions icon.

This article doesn’t cover any of the commands and their meanings – use the Microsoft Access database help system for full details.

When saving your macro, you must choose the keyword AutoExec which waits to be triggered the next time you start the database.

Microsoft Access database Auto Starting Sequence

There are several ways to get your Access database to trigger a procedure when starting by using the StartUp option and/or the AutoExec macro and/or the loading event of a form.

The order is as follows:

  1. Startup Option is called first
  2. The AutoExec macro is called second
  3. The loading event of a calling form is called by either of the above.

You typically use the StartUp option to load a Form which could have a macro or VBA procedure attached to the loading event of that form.

You use the AutoExec macro to run several objects and other calling procedures together in the order they are set.

Microsoft Access – One Other Auto Macro

There is another Auto macro worth mentioning and I will cover this on more detail in another post soon called the AutoKeys Macro which sets your keyboard shortcuts at startup and allows you to override default keys. Keep an eye out for this post!

Finally, you can call a VBA procedure within a macro procedure which combines the best of all automated procedures of Microsoft Access.

This entry was posted in Forms, Macros, Modules, MS Access, VBA and tagged , , , , . Bookmark the permalink.

One Response to Microsoft Access Database: Create a macro that runs when you open an Access database

  1. Ben Beitler says:

    To bypass the AutoExec macro and other startup options, hold down the SHIFT key while you start the database.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Confirm you are human.