Results 1 to 6 of 6
  1. #1
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59

    multi stage timer

    Looking to create a simply form that has a button on it.
    When depressed it starts counting (say 5 seconds)
    when it reaches 5 seconds it turns the background a different color
    then counts 5 seconds again and turns background a different color.

    I need to be able to set the time interval and the amount of times through a loop. when it gets to the set number of loops it resets itself waiting for the button to be clicked again.



    Any ideas on how to do this?

  2. #2
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    I am doing this nad I get the timer working well...I am waiting....

    The back ground turns colors BUT ONLY when I have the msgbox in there....if I comment that out it does not turn colors??????/


    Option Compare Database
    'Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Declare Sub AppSleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

    Public Sub PauseApp(PauseInSeconds As Long)

    Call AppSleep(PauseInSeconds * 1000)

    End Sub

    Private Sub StartButton_Click()
    Dim i As Integer
    i = 0
    For i = 1 To 3

    If i = 1 Then
    Forms!Form1.Detail.BackColor = vbGreen
    ElseIf i = 2 Then
    Forms!Form1.Detail.BackColor = vbyellow
    ElseIf i = 3 Then
    Forms!Form1.Detail.BackColor = vbRed
    End If

    MsgBox i
    PauseApp 2
    Next i

    Forms!Form1.Detail.BackColor = vbWhite

    End Sub

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try this:
    Code:
    Private Sub StartButton_Click()
       Const vbGray = -2147483633
       Dim i As Integer
    
       'i = 0   ' <<-- this is not needed
    
       For i = 1 To 3
          If i = 1 Then
             Forms!Form1.Detail.BackColor = vbGreen
          ElseIf i = 2 Then
             Forms!Form1.Detail.BackColor = vbYellow
          ElseIf i = 3 Then
             Forms!Form1.Detail.BackColor = vbRed
          End If
    
          'MsgBox i
          DoEvents
          PauseApp 2
       Next i
    
       'Forms!Form1.Detail.BackColor = vbWhite
       Forms!Form1.Detail.BackColor = vbGray
       
       'comment out next line when debugging complete
       MsgBox "Done"
       
    End Sub

  4. #4
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    why does it ONLY work with the message box...what am I doign wrong....

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    There needs to be time for the screen to update........

  6. #6
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    Was missing teh DoEvents THANKS

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

Similar Threads

  1. Timer on IIf Statements?
    By athyeh in forum Programming
    Replies: 4
    Last Post: 07-29-2013, 09:54 PM
  2. Debugger and Timer
    By DepricatedZero in forum Programming
    Replies: 2
    Last Post: 05-29-2013, 01:15 PM
  3. Replies: 2
    Last Post: 10-31-2012, 11:52 AM
  4. Timer object
    By joki in forum Programming
    Replies: 7
    Last Post: 03-17-2011, 08:50 AM
  5. End User Stage
    By KevinMCB in forum Database Design
    Replies: 2
    Last Post: 03-02-2011, 10:47 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