Array VBA
From: GOL (GOL_at_discussions.microsoft.com)
Date: 01/27/05
- Next message: Rick Roberts: "Re: Calling an application Help file from VBA???"
- Previous message: Joel: "Running crosstab queries from VBA"
- Next in thread: Allen Browne: "Re: Array VBA"
- Reply: Allen Browne: "Re: Array VBA"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 27 Jan 2005 15:11:02 -0800
I have a timer on a subform on a main "order form." I am timing how long it
takes to process different orders. However, if I change orders in the middle
of timing one, the timer does not reset with next order, just keeps on
running. I believe I need some kind of array code so that the timer is
"bound" in a way to each record (or order). I would like to be able to click
and time different orders at the same time simultaneously--but can only do
one at a time now, and have to reset timer for every order or else it picks
up where last stopped. Here is my current code, which I got from the MS
site. Just in case you don't want to look at the site,the code is below.
Help is GREATLY appreciated. I have worked on this problem for weeks!!!
Option Compare Database
Option Explicit
Dim TotalElapsedMilliSec As Long
Dim StartTickCount As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub cmdStartStop_Click()
If Me.TimerInterval = 0 Then
StartTickCount = GetTickCount()
Me.TimerInterval = 15
Me!cmdStartStop.Caption = "STOP"
Me.cmdStartStop.ForeColor = RGB(255, 0, 0)
Me.cmdStartStop.FontSize = "8"
Me!cmdReset.Enabled = False
Else
TotalElapsedMilliSec = TotalElapsedMilliSec + (GetTickCount() -
StartTickCount)
Me.TimerInterval = 0
Me!cmdStartStop.Caption = "Start the Timer"
Me.cmdStartStop.ForeColor = RGB(0, 64, 128)
Me.cmdStartStop.FontSize = "8"
Me!cmdReset.Enabled = True
End If
End Sub
Private Sub cmdClose_Click()
DoCmd.Close acForm, "frmStopWatch", acSaveNo
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() - StartTickCount) + TotalElapsedMilliSec
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!ElapsedTime = Hours & ":" & Minutes & ":" & Seconds & ":" & MilliSec
End Sub
Private Sub cmdReset_Click()
TotalElapsedMilliSec = 0
Me!ElapsedTime = "00:00:00:00"
End Sub
- Next message: Rick Roberts: "Re: Calling an application Help file from VBA???"
- Previous message: Joel: "Running crosstab queries from VBA"
- Next in thread: Allen Browne: "Re: Array VBA"
- Reply: Allen Browne: "Re: Array VBA"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|