|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
My application opens a series of forms, all non-modal; most have a Form_Load procedure. Everything works fine, except in this one case: If the series of forms is open and Access is shut down by closing the top-level window or by executing a Quit command, one form’s Load procedure runs during the shutdown process, showing all sorts of error messages, because resources needed by the load event are being or have been shut down. This happens most of the time, but not consistently (indicating perhaps a timing dependency or race condition?), and appears in both 2002 and 2003 versions. Inserting DoEvents did not help. Has anyone seen this before? What might cause it? I solved this by moving the offending form’s startup code from the Load to the Open event, and that cleared it up, but that avoids the symptom instead of providing a cure. Any thoughts?
-- Ted
|
|
"TedMi" <TedMi[ at ]discussions.microsoft.com> wrote in message news:B67C3C69-8A3F-4928-840D-32C4838A358F[ at ]microsoft.com
[Quoted Text] > My application opens a series of forms, all non-modal; most have a > Form_Load procedure. Everything works fine, except in this one case: > If the series of forms is open and Access is shut down by closing the > top-level window or by executing a Quit command, one form's Load > procedure runs during the shutdown process, showing all sorts of > error messages, because resources needed by the load event are being > or have been shut down. > This happens most of the time, but not consistently (indicating > perhaps a timing dependency or race condition?), and appears in both > 2002 and 2003 versions. Inserting DoEvents did not help. Has anyone > seen this before? What might cause it? > I solved this by moving the offending form's startup code from the > Load to the Open event, and that cleared it up, but that avoids the > symptom instead of providing a cure. Any thoughts?
Could it be that the Close or Unload event of some other form has code in it that opens the form that's causing the trouble?
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
Dirk: Thanks; I checked, and there is no code in any unload or close event. I tracked it down in more detail: there is a startup formMain which controls all the app functions. If this form has been autoloaded and is open when the the app shuts down; the following sequence of events occurs: formMain Unload formMain Close formLast Load main window closes where formLast is the last form to be opened, via a chain of UI actions that begins on formMain. This created a problem on only one form, where the load event was referencing controls on formMain. All other load events are local to their forms. Note that the Open event is not fired – hence my workaround. However, if formMain is opened manually, or is closed prior to shutdown, or other forms were opened from the db window, then the anomalous Load event does not fire on shutdown. Is that wierd or what? Debugging is not possible, because breakpoints are not honored in code executing during app shutdown, so I'm tracing with MsgBoxes. I will try to rebuild formMain to see if that helps. -- Ted
|
|
"TedMi" <TedMi[ at ]discussions.microsoft.com> wrote in message news:9789970B-0D4B-4DE3-B23D-F1916ED30EA7[ at ]microsoft.com
[Quoted Text] > Dirk: Thanks; I checked, and there is no code in any unload or close > event. I tracked it down in more detail: there is a startup formMain > which controls all the app functions. If this form has been > autoloaded and is open when the the app shuts down; the following > sequence of events occurs: formMain Unload > formMain Close > formLast Load > main window closes > where formLast is the last form to be opened, via a chain of UI > actions that begins on formMain. This created a problem on only one > form, where the load event was referencing controls on formMain. All > other load events are local to their forms. Note that the Open event > is not fired - hence my workaround. However, if formMain is opened > manually, or is closed prior to shutdown, or other forms were opened > from the db window, then the anomalous Load event does not fire on > shutdown. Is that wierd or what? Debugging is not possible, because > breakpoints are not honored in code executing during app shutdown, so > I'm tracing with MsgBoxes. > I will try to rebuild formMain to see if that helps.
That's very odd, and I'm at a loss to explain it if there's no code anywhere along the way that would open the last form again. You're saying it's always the last form loaded whose load event fires at shutdown, but it's not always the same form? I see your forms aren't opened modal, and I suppose they aren't opened in dialog mode; are they popup?
The fact that it only happens when formMain was opened automatically makes it look a lot more like a bug. Is formMain initially opened by the Startup "Display Form/Page" property, or do you use an autoexec macro?
You might try making a copy of the database, decompiling it, compacting it, and recompiling it to see if that makes a difference.
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
The main form opens by virtue of being in the startup properties. There is an Autoexec macro, but it only reconnects to the back end and does no form manilupation. All of the forms open in non-modal, non-popup, non-dialog mode. Yes, verrrry strange. I solved it by recreating formMain - copied all of the controls and code to a new form (I learned long ago to put heavy-duty event code in modules, with just calls in the event procs of the form!) The firing of the spurious Load event went away. Go figure. Thanks for your time. -- Ted
|
|
"TedMi" <TedMi[ at ]discussions.microsoft.com> wrote in message news:CD707738-E52E-4671-AB58-490134199A04[ at ]microsoft.com
[Quoted Text] > The main form opens by virtue of being in the startup properties. > There is an Autoexec macro, but it only reconnects to the back end > and does no form manilupation. All of the forms open in non-modal, > non-popup, non-dialog mode. Yes, verrrry strange. > I solved it by recreating formMain - copied all of the controls and > code to a new form (I learned long ago to put heavy-duty event code > in modules, with just calls in the event procs of the form!) The > firing of the spurious Load event went away. Go figure. > Thanks for your time.
Thanks for sharing an interesting phenomenon. I've never heard of that one before. I'd guess it's some sort of corruption, but that's only a catch-all sort of guess.
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
|