PRB: Form No Longer Modal When Close Event CanceledArticle ID: Q129305Creation Date: 24-APR-1995 Revision Date: 19-SEP-1996
The information in this article applies to:
SYMPTOMS
When you open two forms as modal forms and then cancel the Close event for
the top form with a macro or function, both forms are no longer modal. You
can switch from one form to the other. When you close the top form, the
bottom form becomes modal again.
RESOLUTION
If you need to have two modal forms open and you need to have the Close
event canceled for one of the forms, upgrade to Microsoft Access version
2.0. The behavior described above does not occur in Microsoft Access
version 2.0.
MORE INFORMATION
Steps to Reproduce Behavior
1. Open a new Microsoft Access database.
2. Create a new module and add the following line to the Declarations
section:
Option Explicit
3. Enter the following code in the module:
Function BeforClosing()
If forms!Form1!canClose=0 Then
DoCmd CancelEvent
DoCmd SelectObject a_form, "form1"
End If
End Function
Function CloseMe()
Dim curForm as Form
Set curForm = screen.activeform
curForm![CanClose] = 1
DoCmd Close a_form, "form1"
End Function
4. Create a new blank form and set its Modal property to Yes. Save the
form as Form1.
5. Add a text box to the Form1 form and set the following properties:
Name: CanClose
DefaultValue: 0
6. Add a command button to the form and set the following property:
OnPush: =closeMe()
7. Set the following property for the Form1 form:
OnClose: =beforClosing()
8. Close the Form1 form.
9. Create a second new blank form and set the Modal property to Yes. Save
the form as Form2.
|
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.