When you delete a record in a form, Access displays a standard message box, asking you to confirm the deletion. But you are not limited to this message; you can create your own message text to include a reminder or other information. Follow these steps:
- Open the database, and click Macros under Objects.
- Click New.
- Right-click the macro title bar and select Conditions. (In Access 2002, click the Conditions button in the Macro toolbar.)
- Click in the first Conditions cell and enter the
MsgBox("Do you really want to delete the record?"273,"Delete")<>1
- Click in the Action cell and enter CancelEvent.
- Click in the next Condition cell.
- Enter an ellipsis (...).
- Press [Tab].
- Enter StopMacro.
- Click in the next Action cell.
- Enter Keystrokes.
- Under Action Arguments, click in the Keystrokes box and click [Enter].
- Close and save the macro as ConfirmDelete.
- Open the form in design view, then right-click the form and select Properties.
- On the Event tab, click in the On Delete property box and select ConfirmDelete.
You can modify the message in step 4 to be any text you like. The macro will execute before the system actually deletes the record.
Miss a tip?
Check out the Microsoft Access archive, and catch up on our most recent Access tips.
Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.