Microsoft KB Archive/210376

= ACC2000: Cannot Close Form from Control's OnExit Property =

Article ID: 210376

Article Last Modified on 7/15/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210376



Novice: Requires knowledge of the user interface on single-user computers.



SYMPTOMS
When you try to close a form from one of the following

the OnExit, OnEnter, OnLostFocus, or OnGotFocus property of a control on the form

-or-

the OnCurrent property of the form

you may receive the following error message:

This action can't be run while processing a form or report event.



CAUSE
A macro or procedure that closes the active form is called from a control's OnExit, OnEnter, OnLostFocus, or OnGotFocus property.



RESOLUTION
To work around this problem, add a new control that contains a flag to the form. Then, refer to that flag's value before closing the form. The following example demonstrates how to do this.  To the form in question, add a new text box control. Set the new control's Name property to FlagControl. Set its DefaultValue property to 0.  Set the OnExit property of the control from which you want to close the form to the following event procedure: Me![FlagControl]=-1 To create this event procedure, click the OnExit property field, click the Build (...) button to the right of the field, and then select Code Builder. After you enter the code, close the module.  On the Edit menu, click Select Form. Set the form's TimerInterval property to 500.  Set the form's OnTimer property to the following event procedure: If Me![FlagControl] Then DoCmd.Close End If                   </li> View the form in Form view, and then exit the control (either by pressing TAB or by clicking another control).</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Problem
<ol>  Set the OnExit property of any control on a form to the following event procedure: DoCmd.Close </li> View the form in Form view, and then exit the control (either by pressing TAB or by clicking another control).</li></ol>

Additional query words: prb can t

Keywords: kberrmsg kbprogramming kbprb KB210376

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.