[AccessD] Resize Event / maximized

William Benson (VBACreations.Com) vbacreations at gmail.com
Fri May 6 08:51:13 CDT 2011


Hi,

I have been playing with some code which is meant to run when a form is
resized. I have this code, on a test form.

Option Compare Database
Option Explicit
Dim mbUnloading As Boolean

Private Sub Form_Load()
     Debug.Print "Load"
End Sub

Private Sub Form_Resize()
     If mbUnloading Then Exit Sub
     Debug.Print "Resize"
End Sub

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


The result in the immediate window varies based on the size condition the
form had at last time it was closed. If the form was not maximized, the
resize event is called only once according to the immediate window results.
But if the form WAS maximized at the time it was last closed, the word
"Resize" appears 3 times in the immediate window. WOW. That means it is
running my code in that event in triplicate. Any idea why? 

Also, if I put DoCmd.Maximize in the Load event, then whether the form had
last been closed maximized or not, the Resize Event is fired three times on
form Load. That as opposed to only once if I had DoCmd.Maximize in a button
click event and clicked it - then it occurs only once. So, any idea why
Maximizing during the Load event makes Form_Resize be called three times
instead of twice? In fact,  since multiple clicks of the command button that
maximizes will not cause the Resize event to fire, it makes no sense to me
that when the form had last been closed in Maximized window, Resize should
be called any more than ONCE during this procedure:
	Private Sub Form_Load()
	     DoCmd.Maximize
	End Sub




More information about the AccessD mailing list