Awards
Join OfficeTipsAndMethods

Have some suggestions to share with the world?

Join OfficeTipsAndMethods and share your insight in a Comment. You must be a member to comment and all comments are moderated before being published. Membership is free and we would never share your personal information with anyone.

Become an OTM Member

Log In

YouTube Video Channel
OfficeFix
Article Categories

Archive for the ‘Access Data Macros’ Category

Data Macros

Use Data Macros to add logic to events that happen in Tables, this could be adding records, updating a record or deleting data. Data macros are created and managed from the Table ribbon tab while you are working in the table view. There are two main types of data macros

  • Event Driven, which are those triggered by table events.
  • Named, which run in response to being called by name.

Creating a Data Macro

One of the common uses of Data Macros is to validate data being entered into a record. The following example will stop the creation of a record in the Asset table if the user is trying to add a warranty value if they have not entered an Aquired Date.

Procedure: Create a Data Macro

1. Open into Data Sheet view the Table you are adding the Data Macro to.

2. Select the Table ribbon view tab.

image

3. Click in this instance the Before Change button.

4. Within the Macro screen, add the necessary actions you require. This example shows an If program flow

image

Add the necessary values

image

 

 

 

 

 

 

 

 

 

 

 

5. When you have completed the Macro, Save and Close the Data Macro.

image

The next time a new or edited record does not meet the validation set, the following message will appear and stop the update of the Record.

image

Procedure: Edit a Data Macro

1. Open into Data Sheet view the Table you wish to edit the Data Macro for.

2. Select the Table ribbon view tab. You will notice the Event button will appear yellow if there is already a Data Macro created.

3. Select the relevant Event button and make the necessary changes.

image

4. When you have completed the Macro, Save and Close the Data Macro.

Procedure: Delete a Data Macro

1. Open into Data Sheet view the Table you wish to Delete the Data Macro for.

2. Select the Table ribbon view tab.

3. Select the relevant Event button and make Delete the changes for.

4. Within the Data Macro screen, remove each command by selecting the at the top right corner of the command.

image

5. When you have completed the Macro, Save and Close the Data Macro.

image

This article was written by Nick Williams. Nick is one of the Access course tutors at Acuity Training, a hands-on IT training company with offices in central London & Guildford UK.