[AccessD] Resize Event / maximized

Charlotte Foust charlotte.foust at gmail.com
Fri May 6 12:27:32 CDT 2011


Resize may fire more than once, because it DOES remember the last
window setting but it doesn't go straight to that setting.  It passes
through other settings to get there.  In addition to your unloading
variable, you need a resize variable at the form level that you set
when you open the form.  Test for the variable in the routine where
you want to run you code, and only run it if the variable is false.
Set the variable to true and your code won't run again until the form
is reopened.

Charlotte Foust

On Fri, May 6, 2011 at 6:51 AM, William Benson (VBACreations.Com)
<vbacreations at gmail.com> wrote:
> 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
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>




More information about the AccessD mailing list