- Local time
- Today, 10:30
- Joined
- Feb 28, 2001
- Messages
- 30,557
I have a situation I can research for myself but if someone has run across this and already knows the answer, it would make my life easier. If not, I may just have discovered a "nasty" that eventually would have to be reported to Uncle Bill.
When developing a form that includes some auditing code, I am able to see that switching the form from Design View to Form View fires the Open event. Things I want to have happen in the event happen. In particular, some form context variables (in the form's general declaration area) are loaded based on a lookup table. This works OK.
Where I come to grief is when I try to switch back to Design View. The Unload event fires as though I'm going to close the form - but the context variables in the general declaration area have already been dereferenced. This happens before I have the chance to set the Cancel option of the Unload event entry. Therefore, my code makes the wrong choice. If I close the form using a more traditional method like a close button or the upper-right-corner X box, the context variables are still valid during the Unload event and the correct decisions are made. In fact, the context in that case appears to be valid trhough the Close event.
Has anyone else seen this behavior and do you know if anyone has reported this problem to Microsoft? I guess what I wanted to have happen would have been that the form's declarations stay valid until after the completion of the form's Close event. THEN switch to design view.
Does anyone see a problem with the idea that a form's declaration area variables shouldn't be destroyed until the Close event (rather than before the Unload event)?
When developing a form that includes some auditing code, I am able to see that switching the form from Design View to Form View fires the Open event. Things I want to have happen in the event happen. In particular, some form context variables (in the form's general declaration area) are loaded based on a lookup table. This works OK.
Where I come to grief is when I try to switch back to Design View. The Unload event fires as though I'm going to close the form - but the context variables in the general declaration area have already been dereferenced. This happens before I have the chance to set the Cancel option of the Unload event entry. Therefore, my code makes the wrong choice. If I close the form using a more traditional method like a close button or the upper-right-corner X box, the context variables are still valid during the Unload event and the correct decisions are made. In fact, the context in that case appears to be valid trhough the Close event.
Has anyone else seen this behavior and do you know if anyone has reported this problem to Microsoft? I guess what I wanted to have happen would have been that the form's declarations stay valid until after the completion of the form's Close event. THEN switch to design view.
Does anyone see a problem with the idea that a form's declaration area variables shouldn't be destroyed until the Close event (rather than before the Unload event)?