How do I close a Message Box after so many seconds?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Connelly
    New Member
    • Jan 2011
    • 103

    How do I close a Message Box after so many seconds?

    Hello,
    I am building a simple application that after contestants enter their information and submit, a Message box appears and confirms their entry. I have an okay button, but if they walk away, I want to timeout and close the message box after lets say 4 seconds. This is a a simple windows form. Can someone help explain what I need to do?
  • michaeldebruin
    New Member
    • Feb 2011
    • 134

    #2
    Maybe try an event but I am not sure. Or try something with a background worker or thread, but I have no idea how to use them in this case. These are only suggestions which you might consider to use.

    Comment

    • arvindps
      New Member
      • Sep 2011
      • 8

      #3
      Here is what you do

      - create a class

      - put a custom method ShowMessage(str ing title, string message, int timeout)

      - place a textbox, button, timer

      - place a Form load event
      set timer on with interval mentioned in timeout
      place message and title

      - place a timer_tick event
      use Form.Close()

      - show it as a dialog using form.ShowDialog ()


      Now add the class and Call the showmessage method in your application

      Comment

      • john garvey
        New Member
        • Jan 2011
        • 50

        #4
        Hi

        I use the following. Create a form (with no caption bar if you know how) put your message on the form but don't put a button on the form instead place this code in the class module.

        Code:
        Option Compare Database
        Option Explicit
        
        Private Sub Form_Open(Cancel As Integer)
            ' Set timer for 5 seconds
            Me.TimerInterval = 5000
        End Sub
        
        Private Sub Form_Timer()
            If Me.TimerInterval <> 0 Then
                Me.TimerInterval = 0
            End If
            DoCmd.Close acForm, Me.Name
        End Sub
        Last edited by Niheel; Oct 10 '11, 08:05 PM.

        Comment

        Working...