Creating macros is not as difficult or as scary as it sounds. Access makes it easy to set up a macro that will give you the automation you need without having to learn an entire programming language.
Macros are incredibly useful tools that can save you a lot of time. However, knowing they exist is clearly not enough. You have to learn how to create them to really get the full idea of what they can do.
Marcos are coded in a programming language called Visual Basic Applications, or VBA. However, it is not necessary to know VBA to create macros in Access. The Macro Builder gives you a tool where you can create and modify macros.
A word of caution about macros – when designed incorrectly, they can damage or destroy your data. If you encounter issues because a macro deleted records or has become corrupted, contact an Access db repair expert for assistance.
Defining the Macro Builder and Opening It
The macro builder is a fantastic tool if you don’t want to learn a programming language. As a beginner, you can use Macro Builder to create a tool that you can use within a few minutes.
To access the Macro Builder, click on the Create tab > Other > Macro. Some versions of Access do not have Macro at this point. If you do not see it, a Macro button should appear as a button under Module or Class Module.
The screen that appears is the Macro Builder.
Macro Builder Options
There are three columns on the Macro Builder screen: Action, Arguments, and Comment:
- Action defines what is being done.
- Arguments provide information on how to complete the action.
- Comments are there for you to know what action is being done.
You add commands from the Design tab. There are pre-defined commands for your macros:
- Single Step
- Insert Rows
- Delete Rows
- Show All Actions
- Macro Names
You can do a little research to get an idea of what all of the actions are and how to use them. If you are more adventurous (and aren’t developing on a live database), you can test them out.
Create a Macro
You’ve learned most of the basics. Now it is time to create your first macro. You should already have the Macro Builder open to get started.
Make sure you are working in a database that does not have live data. This should be a sandbox area so you can continue to develop the macro.
- Go to the Action column and place the cursor in the first empty cell.
- Select the action you want to use from the drop down menu, such as MsgBox. This will create a message box that displays based on the argument. Notice a box appears at the bottom called Action Arguments.
- Go to the Action Argument box and select the arguments you would like to use for the action.
For a message box, you can provide the text the box displays (Message field), whether the box will beep, and a few other options.
You may not have any arguments. If that is the case, you can skip this step.
Notice that the arguments you add here automatically appear under the Arguments column.
- Add another action under the Actions column, then add the arguments. You can add as many as you like.
- Click the Run button to run the macro. This is the best way to test to see if it works as you intended.
Victor Ren is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair xlsx file and word recovery software products. For more information visit www.datanumen.com