Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
A Before Delete macro allows you to perform an action right before you try and delete a record. For example, if I scroll down to my navigation pane and open up my Products Split Form. I want to make sure that no one tries to delete any of my products. If they do, then anyone who has ordered one in the past will have errors in their order history. Instead, we want them to uncheck this box to show that the product is no longer active. To set up this Before Delete event, go to the Layout View for the form. Go to the Property Sheet and in the box at the top choose Form, because we want this to be triggered for the whole entire form not a specific field or form part.
I'll click down here in Before Delete Confirm. Now there are two different approaches I can take to this macro. Notice I've got a dropdown and a Build button. Since we're going to generate a message box asking them to uncheck the active check box, if I could use that in more than one form, then I should make it as a stand-alone macro by going to the Create tab and making a Macro and then choosing it off this dropdown list. But in this case, our error message is going to be specific to this form. So I'm going to use the Build button.
We're going to build the macro right into the delete event. I'll click OK. Click on the Show All Actions button. If you don't, you'll be limited to just the most popular commands. I'll dropdown my macro box, and scroll down to MessageBox. The message that I want to send the user is Please inactivate it instead. I do want my dialog box to Beep. Where it says Type, I'll drop this down. This is the image that's going to be in the box.
Information will put up an I. This one will give me an exclamation point. The Warning with the question mark will give me a question mark. We want Critical, a big red X. Title is the message including that's going to be in the blue bar at the top of the dialog box. I'll enter in Do Not Delete This Record. Now after the message box pops up, we still don't want them to have the opportunity to delete the message. So, next, we're going to cancel the event. That will stop the deletion in its tracks.
Go up to the ribbon and choose Close. Save the macro, and now let's see it in action. Go back to the Form View. Down at the bottom, click on the gray box next to one of our products, come up to the Ribbon, and try and delete it. Here is our warning. Do Not Delete This Record! Please inactivate it instead. I'll click OK, and instead of getting the message telling me that it's about to delete one record, nothing at all happens. A Before Delete event is a handy way of taking an action before deleting content from your database.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.