Autoexec macro runs before the other actions or vba code; it runs immediately when your database opens. Usually, autoexec macro is used for the main form. When the database first opens, you may want the main form of your database to open before other forms, tables, queries, or reports. To create an autoexec macro is not different from creating other macro actions. For example, when your database first opens, you want log in form to open before other forms; because you need the user to sign in before you can use some forms in the database. To do this task, you need to create an autoexec macro to open the log in form. To create the autoexec macro, follow the steps below:
- Click Create tab
- Click Macro in the Macros & Code group
- Type OpenForm or select OpenForm from the list by clicking the drop-down arrow of Action column.
- Fill in the required information of the action as the figure:
- Click Save to save the macro name AutoExec
- Close your database and then reopen it, you will see the log in form run when your database first open.
Note: Autoexec macro can run is depending on the name of autoexec.
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: