Forum Discussion
Msgbox or Modal window Crash on PC Sleep
This has been an issue for a couple of years, but I haven't spent too much time trying to solve it because I thought it would eventually go away. It hasn't and it is becoming worse as I develop other parts of my application.
Situation: When a msgbox (or modal window) is open and the PC sleeps, the application hangs upon PC awake. There's no way to get out it with ending the process.
To replicate:
- Create and save blank database
- Create one module with a single public test function
- Enter msgbox "Hang Test", vbOkOnly
- Hit F5 to run the code. The message box pops up. Leave it.
- Put PC to sleep manually with windows | power | sleep
- Awaken PC, Access is now frozen.
GPT provides a lot of explanations for this behavior, but it doesn't make sense and must be something that can be addressed.
Windows 11, Version 2606 (Build 20131.20126 Click-to-Run)
3 Replies
Agree with both Gustav and George.
I can't think of any sensible reason for sending Windows to sleep with an active dialog running.
However, I also tested your scenario using 365 CC version 2607 20228.20110 with Windows 11.
After restoring from sleep, Access remained fully functional and I was able to close the message box.
Adding a timeout would indeed be a simple way of avoiding this situation.
I also have an example available: New Style Access Message Boxes With Timeout
- George_HepworthSilver Contributor
Gustav beat me to it.
These seems more to me like a case of good operating practices than something that needs a software fix.
Don't walk away leaving an open Msgbox or modal window.
Work around it - that seems like your only option:
- Don't let the pc go to sleep
- Use a custom messagebox that offers a time-out like my VBA.ModernBox