Creating User Prompts in Access 2007

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Summary: Learn how to display a custom dialog box in Microsoft Office Access 2007 to prompt users to confirm changes before saving a record.

Office Visual How To

Applies to: 2007 Microsoft Office System, Microsoft Office Access 2007

Joel Krist, Akona Systems

May 2007

Overview

In Microsoft Office Access 2007, by default, users are not prompted to confirm changes after modifying and saving records on a form. But often you might want to prompt users to confirm their changes before the record is saved.

You can use a BeforeUpdate event procedure to display a confirmation prompt and handle a user's response to either cancel or continue with the save.

This visual how-to topic illustrates how to display a custom dialog box to prompt users to cancel or continue with saving changes to a record.

Code It

To illustrate this process, this section describes the following steps:

  • Adding a BeforeUpdate form event procedure to a form.

  • Adding the record save confirmation code to the event procedure.

Adding a BeforeUpdate Form Event Procedure

The first step is to load the form and display it in Design View. Then you add the BeforeUpdate form event procedure to the form.

To add the event procedure

  1. In the Navigation Pane, right-click the form name and select Design View.

  2. In Design View, select the Design tab on the Office Fluent Ribbon.

  3. In the Tools group, click Property Sheet.

  4. On the property sheet, in the Selection list, select Form.

  5. Select the Event tab to display the form's events.

  6. Locate and click the Before Update event, and then click the small down arrow.

  7. Click [Event Procedure], and then click the ellipsis button (...) next to the arrow.

    This loads Visual Basic and displays the body of the Form_BeforeUpdate event procedure.

Adding Code to the BeforeUpdate Event Procedure

The next step is to modify the Form_BeforeUpdate event procedure so that it uses the MsgBox function to prompt the user to confirm changes and save a record in the form.

The following code checks the return value from the MsgBox call. If the user responds No to the confirmation, the code sets the Cancel argument that is passed to the event procedure to True, which tells Access to cancel the record save.

Read It

Frequently you want users to confirm that they want to save changes to records that they have modified in Access 2007 forms. You can use a BeforeUpdate event procedure to display a confirmation prompt and handle a user's response to either cancel or continue with the save.

The key steps in this process are as follows:

  1. Add a BeforeUpdate form event procedure to a form.

  2. Add the record save confirmation code to the BeforeUpdate event procedure.

See It Creating User Prompts In Access 2007

Watch the Video

Video Length: 00:03:32

File Size: 2.37 MB

File Type: WMV

Explore It