Opening/Closing form tip
am 15.11.2007 15:26:27 von Salad
I have a form that opens another (intermediary) form. The user selects
an option on the intermediary form and it opens another form and the
intermediary form is closed. Ex:
From MainForm
Docmd.Openform "IntermediaryForm"
This is what I had as code when an option was selected in
"IntermediaryForm".
DoCmd.Close acForm, "IntermediaryForm"
DoCmd.OpenForm "NextForm"
It looks OK. Does what it's supposed to. But it's not OK. At least my
case.
By closing "IntermediaryForm" first this returns focus back to the
MainForm briefly. This kicks off the OnActivate event of the
Main/Calling form before opening "NextForm". My OnActivate in the
MainForm runs a few routines that slowed down the opening of
"IntermediaryForm"
However, if I switch the calls to
DoCmd.Close acForm, "IntermediaryForm"
DoCmd.OpenForm "NextForm"
the OnActivate event from the MainForm does not get executed needlessly.
A simple reversing of 2 code lines can make a difference...at least in
my case.
B Goode
http://www.youtube.com/watch?v=d-c43wUn2VM
Re: Opening/Closing form tip
am 16.11.2007 14:38:09 von Salad
Salad wrote:
> I have a form that opens another (intermediary) form. The user selects
> an option on the intermediary form and it opens another form and the
> intermediary form is closed. Ex:
>
> From MainForm
> Docmd.Openform "IntermediaryForm"
>
> This is what I had as code when an option was selected in
> "IntermediaryForm".
> DoCmd.Close acForm, "IntermediaryForm"
> DoCmd.OpenForm "NextForm"
>
> It looks OK. Does what it's supposed to. But it's not OK. At least my
> case.
>
> By closing "IntermediaryForm" first this returns focus back to the
> MainForm briefly. This kicks off the OnActivate event of the
> Main/Calling form before opening "NextForm". My OnActivate in the
> MainForm runs a few routines that slowed down the opening of
> "IntermediaryForm"
>
> However, if I switch the calls to
> DoCmd.Close acForm, "IntermediaryForm"
> DoCmd.OpenForm "NextForm"
> the OnActivate event from the MainForm does not get executed needlessly.
Hmmmm...I meant
DoCmd.OpenForm "NextForm"
DoCmd.Close acForm, "IntermediaryForm"
This stops the OnActivate event executing from the original calling form.
>
> A simple reversing of 2 code lines can make a difference...at least in
> my case.
>
> B Goode
> http://www.youtube.com/watch?v=d-c43wUn2VM