Message Box Question

Kodo

"The Shoe"
Local time
Today, 11:06
Joined
Jan 20, 2004
Messages
707
Is there any way to clear a message box after it's popped up without user intervention.

I have a form with an onTimer event that checks the db for certain criteria. If it exists then a msgbox is popped. Problem is, if the user walks away and doesn't click "ok" on the box, I need to terminate that message box and launch the new one.

Suggestions?
 
Create you own custome msgbox which is really a form which looks like a msgbox with a timer in it...

Regards
 
That's what I figured I'd have to do.

Thanks.
 
Disappearing Message Box [Auto Close Message Box]

Kodo said:
Is there any way to clear a message box after it's popped up without user intervention.
Of course there; is if you are willing to use a Windows script. ;)
Try this in a module...

Code:
Option Compare Database
Option Explicit

Public oSHL As Object

Public Function MagicalMessageBox()

        Set oSHL = CreateObject("WScript.Shell")
            oSHL.PopUp "Unless you manually click the OK button within 5 seconds..." & vbCrLf & vbLf & "This message box will magically disappear in 5 seconds.", 5, "Abra Cadabra", vbOKOnly + vbInformation
        Set oSHL = Nothing

End Function
The timer option number preceeds the message box title... 5, "Abra Cadabra",

HTH
 
I am willing! I will inform you of the result! :)
Thanks :D
 
Hmz funny...

I did it yesterday and had the box on my screen for 10 minutes... Now it disappears after 5 secs.... hmz.... Ow well alls well that end well...

What is this WScript?

BR
 
Last edited:
Updated....

Public Function PopUpMessageBox(strMessage As String, lSec As Long, strTitle As String, strButtons As String)

Set oSHL = CreateObject("WScript.Shell")
oSHL.PopUp strMessage, lSec, strTitle, strButtons
Set oSHL = Nothing

End Function

Called as follows..

PopUpMessageBox "This Message will self distruct in 4 Seconds. ", 4, "Boom", vbOKOnly + vbInformation

This way you can call it from any location with a custom message.

HTH

Dave
 
On further thought, wouldn't it be nice to have a popup message without buttons, displays for a second or 2, then dissappears. :)

Dave
 
Last edited:
And a further Update...

Paste this into a module

Option Compare Database
Option Explicit

Public oSHL As Object

Public Function PopUpMsgBox(strMessage As String, Optional lSec As Long = 2, Optional strTitle As String = "Microsoft Access", Optional strButtons As VbMsgBoxStyle = vbOkOnly)

Set oSHL = CreateObject("WScript.Shell")
oSHL.PopUp strMessage, lSec, strTitle, strButtons
Set oSHL = Nothing

End Function


And can be called as follows:

Private Sub cmdPopUp_Click()
'Can be called similarly to a standard MsgBox, but does not return a yes/no result

'Start with a basic message
PopUpMsgBox "This Message is a standard message ! "

'Then add a custom time
PopUpMsgBox "This Message now has a time ! ", 4

'Then add a Title
PopUpMsgBox "And now a Title ! ", 4, "Boom"

'Title, but no time
PopUpMsgBox "Title, but no time ! ", , "Boom"

'Then add custom buttons
PopUpMsgBox "One with the lot ! ", 4, "Boom", vbCritical

'No Title or time ,but a custom button
PopUpMsgBox "Just a Custom button ! ", , , vbCritical

End Sub
 
wow! 6 years later and it still works. Thanks for posting this - saved me a lot of heartache!

Cheers
 

Users who are viewing this thread

Back
Top Bottom