lamwaiman1988
lamwaiman1988

Reputation: 3742

MsgBox made with wscript.shell won't close automatically in this case

I am writing an .mdb file in ms-access, and with a form inside.

I've made a Subroutine to show a msgbox which will close automatically after some secs.

Sub TimedMsgBox(Message As String)

CreateObject("wscript.shell").PopUp _
        Message & vbCrLf & vbCrLf & _
        "This message self-closes in 2 seconds...", 2, "Message"

End Sub

When the msgbox popup, I wait and it close automatically, however, if I change my focus to other application such as firefox, the message will just wait for my attention and didn't close after the selected seconds.(i.e: it is not counting the seconds.) When I change my focus back to it, then it will count the seconds then exit.

How can I made it automatically disappear after some seconds no matter what I am doing?

Upvotes: 1

Views: 1128

Answers (1)

Taryn
Taryn

Reputation: 247680

If it is possible my suggestion would be to create a form instead of a msgbox. Then you can use the On Timer event on the form to automatically close after a period of time.

In my database I have a mainform that gets loaded by the users but when that form opens, I also open a hidden 'ExitForm'. This exit form has a timer event that closes the database at a certain time of night.

You might be able to do something similar.

Upvotes: 3

Related Questions