Microsoft KB Archive/210734

= OFF2000: Exit Event for TextBox in a Frame Does Not Run Correctly =

Article ID: 210734

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition
 * Microsoft FrontPage 2000 Standard Edition
 * Microsoft Outlook 2000 Standard Edition
 * Microsoft PowerPoint 2000 Standard Edition
 * Microsoft Publisher 2000 Standard Edition
 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q210734



SYMPTOMS
The exit event for a TextBox control does not run when you click another control on your UserForm, or the exit event runs after the UserForm closes.



CAUSE
This problem occurs when you add a TextBox control to a Frame in a UserForm, and you assign an exit event to the TextBox. The exit event will run at the correct time only when you click another control within the Frame.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To run the exit event for the TextBox control, put the focus back onto a different control within the Frame. To do this, use the SetFocus method of any other control inside the Frame.

The macro example below illustrates how to run an exit event for TextBox1 when TextBox1 is within a Frame, and CommandButton1 is outside the Frame. When TextBox1 has the focus and you click CommandButton1, the exit event for the TextBox runs before the message box in CommandButton1_Click appears. If you do not shift the focus to Frame1, the exit event for TextBox1 runs after the message box for CommandButton1_Click appears.

This example assumes a UserForm that contains a Frame control, two TextBox controls inside the Frame, and a CommandButton control outside the Frame. Private Sub CommandButton1_Click TextBox2.SetFocus MsgBox "Button Click" End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) MsgBox "Box 1 exit" End Sub



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



MORE INFORMATION
When a UserForm contains a Frame with one or more TextBox controls that contain exit events, the events do not run at the correct time when you click outside the Frame. For example, consider a UserForm that contains two TextBox controls, TextBox1 and TextBox2, within a Frame1 control, and a CommandButton1 outside the Frame. The exit event for TextBox1 does not run when you click CommandButton1. To correct this problem, set the focus to TextBox2 in your CommandButton1_Click subroutine, as illustrated in the "Workaround" section of this article.

Additional query words: OFF2000 XL2000 text box edit

Keywords: kbbug kbdtacode kbnofix kbprogramming KB210734

-

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

© Microsoft Corporation. All rights reserved.