close form automatically after say 2 second

S

Song Su

I guess I cannot close msgbox after predetermined time in code. So I want to
use a form to display message and close automatically in 2 seconds. How to
do that?

Thanks.
 
S

Song Su

These code works. How to supply message to the form in code?

Option Compare Database
Option Explicit

Private Sub Form_Open(Cancel As Integer)

Me.TimerInterval = 2000

End Sub

Private Sub Form_Timer()
DoCmd.Close acForm, "Form1"
End Sub
 
S

SteveM

If you supply a value for the OpenArgs when calling the form, you can set a
textbox to equal the value of OpenArgs.

Code to call form:
DoCmd.OpenForm "Form1",,,,,, "Message to display"

Then in the OnOpen event of Form1:
Me.Field = Me.OpenArgs

Steve
 
S

Song Su

Thank you. I'll try that.

SteveM said:
If you supply a value for the OpenArgs when calling the form, you can set
a
textbox to equal the value of OpenArgs.

Code to call form:
DoCmd.OpenForm "Form1",,,,,, "Message to display"

Then in the OnOpen event of Form1:
Me.Field = Me.OpenArgs

Steve
 
Top