How to use the autoexec macro

The autoexec macro is used to run actions when the database is opening. For example, you may wish to perform a data update before the system becomes active. You can do a similar thing with the start up options, but the autoexec macro will allow you to run more than one action.

Lets look at how we can use the autoexec Access macro to open a form and move to a blank record for entering data.

Load up a database.

Go into the macro designer.

In Access 2010 at the Ribbon you would first click on the create tab.

Then click on the macro icon at the far right hand side.

In the action column select the ‘OpenForm’ action.

 

You will see the following screen…

Set the form name to the name of the form you wish to open.

Make sure that the view option is set to ‘Form’.

On the right hand side of the screen you will see a box called the ‘Action Catalog’.

Under the database objects folder select the action of ‘GoToRecord’.

 

Set the object type to ‘Form’.

Set the object name to the name of the form  you are opening.

Set the record to ‘New’.

 

That’s it…..

Now just save the macro with the name of ‘Autoexec’.

Close the macro designer window.

Exit the database.

Now run the database.

The autoexec Access macro will immediately kick in and you will be taken to a brand new record in the form you specified.

The autoexec macro enables us to control what we want to take place when the database is opening.

Click here MS Access macro if you want to learn more about macros.

Tags: , ,