Message box

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hi

Am using Access 2002.

Is it possible to have a message box appear on screen, for say 10 sec, and
then automatically disappear?

If so how can that be achieved?

TIA

Tom
 
You can't automatically close a message box after a time.

However, it's dead easy to create a little form that looks like a message
box, open it modally, and use its Timer event to close it.

1. Create a new unbound form, with a label control named (say) lblMsg.

2. Set these properties:
Popup: Yes
Modal: Yes
Timer Interval: 10000
On Load: [Event Procedure]
On Timer: [Event Procedure]

3. Click the Build button (...) beside the On Load property.
Access opens the code window.
Enter these 3 lines:
Private Sub Form_Load()
If Me.OpenArgs <> vbNullString Then
Me.lblMsg.Caption = Me.OpenArgs
End If
End Sub

4. Click the Build button (...) beside the On Timer property.
Access opens the code window.
Enter this line:
Private Sub Form_Timer()
DoCmd.Close acForm, Me.Name
End Sub

5. Save the form with a name such as fdlgMsg.

Now instead of MsgBox, call it like this:
DoCmd.OpenForm fdlgMsg, WindowMode:=acDialog, _
OpenArgs:="Now you see me; now you don't."
 
You can create a form and set the timer to close the form after ten seconds.
Type 10000 in the timer interval box.
 
<picky>
Actually, you can close a message box, but only if the message box has an
active Close button (the X in the upper right-hand corner). See my May, 2005
"Access Answers" column in Pinnacle Publication's "Smart Access". You can
download the column (and sample database) for free at
http://www.accessmvp.com/DJSteele/SmartAccess.html
</picky>

That having been said, I'd agree that a custom form is the appropriate
solution.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Allen Browne said:
You can't automatically close a message box after a time.

However, it's dead easy to create a little form that looks like a message
box, open it modally, and use its Timer event to close it.

1. Create a new unbound form, with a label control named (say) lblMsg.

2. Set these properties:
Popup: Yes
Modal: Yes
Timer Interval: 10000
On Load: [Event Procedure]
On Timer: [Event Procedure]

3. Click the Build button (...) beside the On Load property.
Access opens the code window.
Enter these 3 lines:
Private Sub Form_Load()
If Me.OpenArgs <> vbNullString Then
Me.lblMsg.Caption = Me.OpenArgs
End If
End Sub

4. Click the Build button (...) beside the On Timer property.
Access opens the code window.
Enter this line:
Private Sub Form_Timer()
DoCmd.Close acForm, Me.Name
End Sub

5. Save the form with a name such as fdlgMsg.

Now instead of MsgBox, call it like this:
DoCmd.OpenForm fdlgMsg, WindowMode:=acDialog, _
OpenArgs:="Now you see me; now you don't."

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Tom said:
Hi

Am using Access 2002.

Is it possible to have a message box appear on screen, for say 10 sec,
and then automatically disappear?

If so how can that be achieved?

TIA

Tom
 
Back
Top