Timed PopUp message in Ms Access

There are situations in which using certain actions need to display a message, but do not involve our action closure; for example, a number of successive updates.

A simple option would be with a little VBA help.

Public Function fcPopUpTimer(sText As String) As String
CreateObject("WScript.Shell").PopUp sText, 2, "Mesaj atentionare", 0 + 48
End Function

Fig. 1

In the example above, sText is the variable that implies the text that can be displayed, depending on the context (for example: “S-a realizat update-ul primei tabele!“, the number 2 represents the number of seconds the message will be displayed, set 0+48 deals with the type of button that will be displayed (0-OK button, 48-exclamation mark). More options for the button and the displayed symbol can be found by accessing the link

Where is necessary, the function is invoked, as in the example below.

Call fcPopUpTimer("S-a realizat update-ul primei tabele!")

The effect can be observed in Figure 1.

A more sophisticated variant, for the same function (fcPopUpTimer), may involve different interactions, depending on the button pressed. Thus, the function might look like below.

Public Function fcPopUpTimer(sText As String) As String
Dim WshShell, btn
Set WshShell = CreateObject("WScript.Shell")
btn = WshShell.PopUp("Vreti sa continuam update-ul?", 3, "Mesaj atentionare", 4 + 48)
Select Case btn
Case 6 ' Actionarea butonului Yes
MsgBox "O decizie recomandabilã.", vbExclamation, "Actiune"
Case 7 ' Actionarea butonului No
MsgBox "Vom face update altadatã.", vbCritical, "Anulare"
Case -1 ' Nicio actiune
MsgBox "Se pare cã, încã sunteþi indecis.", vbInformation, "Amânare"
End Select
End Function

The result can be seen in the following figures.

Fig. 2 The first interaction
Fig. 3 Pressing the Yes button
Fig. 4 Pressing the No button
Fig. 5 Waiting (no action)

Author: Ovidiu.S

I am quite passionate about this professional area as if I know something - no matter how little - I want to share it with others.

Leave a Reply