Results 1 to 12 of 12
  1. #1
    Norm is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jun 2017
    Posts
    9

    Timer in Message code not working... VBA

    Hi guys
    Spent too much time in trying to get the timer to work and not sure why it’s not working.
    The message is displayed and I can also access other parts of the application with the mouse, but it doesn’t automatically disappear after the 2 seconds and stays open until I click it.
    Also not sure what the wscript.shell is ?
    Please see code below
    The Above wrong I have Windows 10 64 bit


    Appreciate your help
    ‘---------------------------------------------------
    Private Sub Command0_Click()
    Test1 = Hope this works”
    Dim acktime As Integer, infobox As Object
    Set infobox = CreateObject("wscript.shell")
    Acktime = 2
    Select Case infobox.PopUp(test1, acktime, "Test message", 0)
    Case 1, -1
    End Select
    ‘---------------------------------------------------
    end Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    the form is the timer.
    set property: TIMERINTERVAL = 10000 (10 seconds)

    the the event:
    Code:
    sub form_Timer()
       msgbox "my message"
    end sub

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    but it doesn’t automatically disappear after the 2 seconds and stays open until I click it.
    Not clear if you mean a messagebox or a popup form.

    If it's a self-closing messagebox, consider a TaskBox.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    Norm is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2017
    Posts
    9
    Thank you ranman256 for your help.
    But I think you misunderstood my problem or I didn’t explain it clearly enough.
    I would like the message to appear for only 10 seconds NOT come up in 10 seconds.
    In other words…Display the message straight away and close automatically in 10 seconds.
    Moke123
    Thank you as well.
    Yes its a message box. I will try your code and work it out how to remove the bar .
    Extremely close to what I want.

    Most appreciated guys.
    Norm

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    You could do whatever in the code (open form that mimics a message box?) then call a custom timer to which you pass the pause amount (e.g. Pause 5). Next line of code closes the message form. There are lots of examples of this code. I've modified it to accept fractional seconds for when there are lots of loops involved.
    Code:
    Sub pause(sngSecs As Single)
    Dim endTime As Long
    
    endTime = Timer
    Do Until Timer > endTime + sngSecs
    Loop
    
    End Sub
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Here's the link to the threads on TaskBox and how to customize it. https://www.vbforums.com/showthread....a-Task-Dialogs
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #7
    Norm is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2017
    Posts
    9
    Thank guys.
    The code I showed in the first thread works in a new database.
    But not in the one I was using.
    Strange but I giveup.

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Quote Originally Posted by Norm View Post
    Thank guys.
    The code I showed in the first thread works in a new database.
    But not in the one I was using.
    Strange but I giveup.
    I've seen dozens of requests for self closing messageboxes but don't recall ever seeing infobox.PopUp as a solution.

    Could you post a working example?

    From what I've seen googling it, it's buggy and doesn't always work.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  9. #9
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    I cannot help but wonder what is wrong with a simple form that is used in place of a message box and using that form's timer event to close it, or use the Pause function that I posted. No scripting, no Shell, no concerns about 64 vs 32 bit, no bother about missing references for scripting...
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    I have an example with that exact setup - see Customised Message Form + Timer in my example db: Attention Seeking Database (isladogs.co.uk).
    That also includes a task dialog example with a timer
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    Norm is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2017
    Posts
    9
    Thanks again guys.
    Im just a retired person having fun or trying to have fun with msaccess.

    Micron
    I tried your code and it kind of worked.
    When I say kind of. The db froze a couple of times with that code.
    So I must be doing something wrong.
    Moke23.
    That code in my thread 1 is a working version so not sure what you mean.
    I did not expect this to be such an ordeal so I have decided to give this problem a miss.
    The task _dialog looks interesting but i would need days to understand it.
    And this is just a fun hobby for me.
    If I was years younger I would look into it.

    So thanks again but I will stay with the code im familiar with and use a msgbox with a click to close.

  12. #12
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Likely because it doesn't allow for user to do anything while it's running - it wasn't meant for that and I didn't realize that would be your case. Rather than trying Do Events in the calling (or called) code I'd try the timer event of the message form, as long as you don't open that form modal.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-27-2017, 08:21 AM
  2. form timer control code not working sometimes
    By trevor40 in forum Programming
    Replies: 2
    Last Post: 06-16-2016, 05:50 AM
  3. In Use Timer
    By dccjr in forum Programming
    Replies: 7
    Last Post: 09-18-2013, 12:40 PM
  4. Replies: 2
    Last Post: 05-29-2013, 01:44 PM
  5. Replies: 9
    Last Post: 11-22-2011, 05:23 PM

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