I've found an odd situation in where the Load event of the active form
fires (after the Unload event) when Access is closed. I am able to
reproduce this situation in Access 2002 SP3 and Access 2003 on
computers running WinXP. This does not appear to happen in Access 2000
on a computer with Win2000.
This only seems to happen if there is a hidden form also loaded and,
so far, I'm only able to reproduce this if the forms are loaded
through an autoexec macro.
Has anyone else run into this? Is there a solution? Am I doing
something horribly wrong? :-)
I can work around this particular situation, but am concerned that
events may be firing when they're not supposed to.
Steps to Reproduce:
1. launch Access
2. create a new (blank) database
3. create a new form in design view
4. select "View / Code" from the Access menu
5. enter (or copy and paste) the code below
Private Sub Form_Load()
MsgBox "Loading"
End Sub
Private Sub Form_Unload(Cancel As Integer)
MsgBox "Unloading"
End Sub
6. close and save the form as "Form1"
7. create a new form in design view
8. save the form as "Form2"
9. create a new macro
10. select "OpenForm" as the first command in the macro
11. enter or select "Form2" as the form to open and choose
"Hidden" as the Window Mode
12. select "OpenForm" as the second command in the macro
13. enter or select "Form1" as the form to open and choose
"Normal" as the Window Mode
14. close and save the macro as "autoexec"
15. select "Tools / Startup" from the Access menu
16. uncheck the "Display Database Window" option
17. close the database
18. re-open the database. The "Loading" message box should appear.
19. select "File / Exit" from the Access menu, or click the Close
control button on the Access window.
Result: The "Unloading" message box appears. After clicking OK, the
"Loading" message box appears. After clicking OK again, Access closes.
I've also added a button to Form1 that runs the DoCmd.Quit command
when clicked. Clicking the button has the same results (the Load event
fires after the Unload event).
Any ideas are welcomed. Thanks!
-- Dexter Lieu