Forum Discussion

Jlorbz's avatar
Jlorbz
Tin Contributor
Jul 22, 2026

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:

  1. Create and save blank database
  2. Create one module with a single public test function
  3. Enter msgbox "Hang Test", vbOkOnly
  4. Hit F5 to run the code. The message box pops up. Leave it.
  5. Put PC to sleep manually with windows | power | sleep
  6. 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_Hepworth's avatar
    George_Hepworth
    Silver 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