Microsoft KB Archive/208358

= ACC2000: Resize Event Fires Unexpectedly When Changing Form Focus =

Article ID: 208358

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q208358



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
When you switch the focus away from a maximized form in a Microsoft Access database, the Resize event of the form that is losing focus fires unexpectedly.



CAUSE
When the form that is losing focus is in a maximized state and you are changing focus to another maximized object, the form's Resize event occurs. All multiple-document interface (MDI) objects that do not have focus are automatically restored to a windowed state behind the maximized MDI form that has focus. When the current form loses focus, Windows automatically restores it to a windowed state, causing the Resize event to occur.



MORE INFORMATION
The Resize event of a form fires whenever a change occurs that affects the size of a form:
 * When you first open a form.
 * When you resize a form using the keyboard or mouse.
 * When you maximize a form.
 * When you minimize a form.
 * When you switch focus away from a maximized form.

Switching focus away from a maximized form is an additional issue that you must consider when developing custom code that uses the Resize event of a form.

Steps to Reproduce Behavior
 Create a new database called Resize.mdb. Create the following form:

Name: Test1

Caption: TestForm

  Set the form's OnResize property to the following event procedure: Private Sub Form_Resize MsgBox "The Resize Event Fired for " & Me.Name End Sub  Save the form as Test1, and then close it. Open the form in Form view; you receive the following message:

The Resize Event Fired for Test1

Click OK. Press F11 to bring the Database window into focus, and then maximize the Database window.</li> On the Window menu, click 2 TestForm to bring the Test1 form into focus. You receive the following message:

The Resize Event Fired for Test1

Click OK.</li> On the Window menu, click 1 Resize: Database to bring the main database window into focus. You receive the following message again:

The Resize Event Fired for Test1

This occurs because Access is restoring the form to a windowed state as it places it behind the main database window.</li></ol>

<div class="references_section">