ACC2000: Resize Event Fires Unexpectedly When Changing Form Focus (208358)



The information in this article applies to:

  • Microsoft Access 2000

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

  1. Create a new database called Resize.mdb.
  2. Create the following form:

    Name: Test1
    Caption: TestForm

  3. 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
    					
  4. Save the form as Test1, and then close it.
  5. Open the form in Form view; you receive the following message:

    The Resize Event Fired for Test1

    Click OK.
  6. Press F11 to bring the Database window into focus, and then maximize the Database window.
  7. 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.
  8. 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.

REFERENCES

For additional information about the behavior of maximized forms in Microsoft Access, click the article number below to view the article in the Microsoft Knowledge Base:

210123 ACC2000: Maximizing One Form Maximizes All Forms

For additional information about using custom form properties to expose the Maximize and Minimize status of forms, click the article number below to view the article in the Microsoft Knowledge Base:

210190 ACC2000: How to Determine If a Form Is Maximized or Minimized


Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kbprb KB208358