S
Stockwell43
Hello,
I found a Stopwatch database and downloaded it to see how it worked, pretty
cool. Could I click the start button when I open the database to run it and
when it hits certain times have it trigger certain things?
Example:
Once it's running, when it hits 15:00 (15 minutes) run this macro, 02:30:00
(two and a half hours) open this form etc....
There is nothing in the database other than one forma and here is all the
code:
Option Compare Database
Option Explicit
Dim TotalElapsedTime As Long
Dim StartTime As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub cmdTimer_Click()
Me.lblElapsed.Visible = True
If Me.TimerInterval = 0 Then
StartTime = GetTickCount()
Me.TimerInterval = 10
Me!cmdTimer.Caption = "Stop"
Me!cmdReset.Enabled = False
Else
TotalElapsedTime = TotalElapsedTime + (GetTickCount() - StartTime)
Me.TimerInterval = 0
Me!cmdTimer.Caption = "Start"
Me!cmdReset.Enabled = True
End If
End Sub
Private Sub Form_Current()
DoCmd.Restore
End Sub
Private Sub Form_Timer()
Dim Hours As String
Dim Minutes As String
Dim Seconds As String
Dim MilliSec As String
Dim Msg As String
Dim ElapsedMilliSec As Long
ElapsedMilliSec = (GetTickCount() - StartTime) + TotalElapsedTime
Hours = Format((ElapsedMilliSec \ 3600000), "00")
Minutes = Format((ElapsedMilliSec \ 60000) Mod 60, "00")
Seconds = Format((ElapsedMilliSec \ 1000) Mod 60, "00")
MilliSec = Format((ElapsedMilliSec Mod 1000) \ 10, "00")
Me!lblElapsed.Caption = Hours & ":" & Minutes & ":" & Seconds & ":" &
MilliSec
End Sub
Private Sub cmdReset_Click()
TotalElapsedTime = 0
Me!lblElapsed.Caption = "00:00:00:00"
Me!lblElapsed.Visible = False
End Sub
Where would I put code to trigger my examples if I am able to it?
Thanks!!
I found a Stopwatch database and downloaded it to see how it worked, pretty
cool. Could I click the start button when I open the database to run it and
when it hits certain times have it trigger certain things?
Example:
Once it's running, when it hits 15:00 (15 minutes) run this macro, 02:30:00
(two and a half hours) open this form etc....
There is nothing in the database other than one forma and here is all the
code:
Option Compare Database
Option Explicit
Dim TotalElapsedTime As Long
Dim StartTime As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub cmdTimer_Click()
Me.lblElapsed.Visible = True
If Me.TimerInterval = 0 Then
StartTime = GetTickCount()
Me.TimerInterval = 10
Me!cmdTimer.Caption = "Stop"
Me!cmdReset.Enabled = False
Else
TotalElapsedTime = TotalElapsedTime + (GetTickCount() - StartTime)
Me.TimerInterval = 0
Me!cmdTimer.Caption = "Start"
Me!cmdReset.Enabled = True
End If
End Sub
Private Sub Form_Current()
DoCmd.Restore
End Sub
Private Sub Form_Timer()
Dim Hours As String
Dim Minutes As String
Dim Seconds As String
Dim MilliSec As String
Dim Msg As String
Dim ElapsedMilliSec As Long
ElapsedMilliSec = (GetTickCount() - StartTime) + TotalElapsedTime
Hours = Format((ElapsedMilliSec \ 3600000), "00")
Minutes = Format((ElapsedMilliSec \ 60000) Mod 60, "00")
Seconds = Format((ElapsedMilliSec \ 1000) Mod 60, "00")
MilliSec = Format((ElapsedMilliSec Mod 1000) \ 10, "00")
Me!lblElapsed.Caption = Hours & ":" & Minutes & ":" & Seconds & ":" &
MilliSec
End Sub
Private Sub cmdReset_Click()
TotalElapsedTime = 0
Me!lblElapsed.Caption = "00:00:00:00"
Me!lblElapsed.Visible = False
End Sub
Where would I put code to trigger my examples if I am able to it?
Thanks!!