Results 1 to 3 of 3
  1. #1
    wasim_sono is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2005
    Location
    Pakistan
    Posts
    73

    Question Display a message for some time

    Dear All



    I need to display a text message for 5 to 10 seconds as a user press "Save" button.
    I used following code but it goes infinite loops.

    For i = 1 to 1000
    msgbox "Data is saving..." ,vbcritical,"intialization..."
    i = i + 1
    next

    have anyone solution?

    Thanks.

    Wasim

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I foud this question very interesting and here is my solution to your problem.

    In a commandButton of a form I have the following code which displays a message box.


    Option Compare Database
    Option Explicit
    Private Sub Command0_Click()
    Me.TimerInterval = 5000
    MsgBox "Attempting to close msgbox in 5 seconds."
    Me.TimerInterval = 0
    End Sub

    Now in the form time timer event type this code;

    Private Sub Form_Timer()
    'you could use "{Esc}" here
    SendKeys "{Enter}"
    End Sub

    This should solve your problem. if it does mark the thread solved.

  3. #3
    c_smithwick is offline Underpaid Programmer
    Windows 7 Access 2003
    Join Date
    Jan 2010
    Location
    Lakeside, CA
    Posts
    49

    Post

    Put the following in a public module. Should work for what you need (Usage - TimedMsgBox "Your prompt", timeout time in sec, optional style, optional title)
    Code:
    Option Explicit
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, LParam As Any) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    Private strMBTitle  As String
       
    Public Function TimedMsgBox(strPrompt As String, Optional ByVal lngTimeOut As Long = 0, Optional Icon As VbMsgBoxStyle = vbOKOnly, Optional strTitle As String = vbNullString)
       
      Dim lngTimerId As Long
       
      strMBTitle = strTitle
       
      If lngTimeOut = 0 Then
        lngTimeOut = 5 * 1000
      Else
        lngTimeOut = lngTimeOut * 1000
      End If
       
      lngTimerId = SetTimer(0, 0, lngTimeOut, AddressOf TimeOutMB)
      TimedMsgBox = MsgBox(strPrompt, Icon, strMBTitle)
      TimedMsgBox = 0
      KillTimer 0, lngTimerId
       
    End Function
       
    Private Sub TimeOutMB(lngHWnd As Long, lngMsg As Long, lngIdEvent As Long, lngTime As Long)
       
      SendMessage FindWindow(vbNullString, strMBTitle), 16, 0&, 0&
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculate Time and Display Records
    By w2vijay in forum Reports
    Replies: 1
    Last Post: 02-12-2010, 01:58 AM
  2. Report control of a field display/no display
    By systems013 in forum Reports
    Replies: 5
    Last Post: 02-01-2010, 09:44 AM
  3. SendObject Message
    By williammarino in forum Forms
    Replies: 4
    Last Post: 10-06-2009, 01:54 AM
  4. message box help
    By shaz10010 in forum Forms
    Replies: 1
    Last Post: 04-17-2009, 09:11 AM
  5. Message in Field
    By supatsiri in forum Reports
    Replies: 0
    Last Post: 03-09-2009, 01:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums