Home  |  About  |   Search   

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

RunCommand Constants

Terms of Use


 

Bugs: Form_Resize fires after Form_Close on maximized forms

Author(s)
Dev Ashish

To reproduce this problem, create a new form and have this code in appropriate events.

Private Sub Form_Close()
    Debug.Print "Closing..."
End Sub

Private Sub Form_Resize()
   Debug.Print "Resizing..."
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Debug.Print "Unloading..."
End Sub

    If the form is not maximized, the order of events you should receive is

   Resizing -> Unloading -> Closing

    But for maximized forms, this becomes

 Unloading -> Closing -> Resizing

    So, if you have a module level object variable that you're calling from the Resize event, and if you set it to Nothing from the form's Close event, you will likely receive Error 91 (Object variable or With block variable not set).

    The workaround is to use code in the Resize event only if a module-level boolean variable is False;  and set it to true from the form's Close event.


1998-2009, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer