The Modal Dialog Mode

The Modal Dialog form opens as a modal window, which means that the user must respond to and close the form before any other object can have the focus. These are often referred to as modal dialog forms because they typically have the sole purpose of obtaining a specific input or feedback from the user. Once the user has provided the required response, they can close the form and the application can continue its process, whereas a modal form merely needs to be closed before the user can proceed with other processes.

If you have ever created dialog forms, you know how tedious the process can be — setting the same form properties and adding the same command buttons to every form. The Modal Dialog Wizard now does the work and saves you a lot of time. The new form will be essentially blank, except for two command buttons (one labeled OK and the other, Cancel). Both buttons have the Close method for their On Click event, so you will most likely want to change or remove one of the buttons. Because the buttons use an embedded macro, they run in disabled mode. The best part of using the wizard to create a modal dialog form is that the wizard correctly sets the appropriate properties such as the formatting (border style and navigation) and the settings for pop-up and Modal mode.

Creating a new modal form is great, but simple dialog forms aren't the ones that you may want to open in modal mode. Any form or report can be set to open in modal dialog mode by setting the Modal property to Yes or by using code to specify the view as the form is opened. Here are two examples of code that will open a modal form in a modal window:

Docmd.OpenForm

"frmMyModalForm"

, acNormal, ,

, acFormEdit,

acWindowNormal

Docmd.OpenForm

"frmMyModalForm"

, acNormal, ,

, acFormEdit,

acDialog

The first line works only when the form properties specify that the form is modal. The second line can be used to open any form in a modal window — providing that you put the correct form name in the quotes. The difference between the two is the last parameter. It is an optional parameter named WindowMode that specifies the window mode in which the form will open. IntelliSense prompts you through the process of writing the command line and shows the options as the cursor gets to each parameter. WindowMode has the options to use the Access enums acDialog, acHidden, acIcon, and acWidowNormal, but only two apply to modal forms. acWindowNormal opens the form to whatever the form properties state as the default view and style. Stipulating acDialog overwrites the property settings and opens the form in a modal window.

Was this article helpful?

0 0

Responses

  • Neftalem
    How do I close a modal dialog form in MS Access 2007 VBA?
    8 years ago
  • ollie
    How to undo modal mode in access?
    8 years ago
  • Elsie Marshall
    How to create event for modal dialog access 2007?
    7 years ago

Post a comment