Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / December 2004

Tip: Looking for answers? Try searching our database.

VBA HELP PLEASE!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PGL - 20 Dec 2004 17:40 GMT
I created a timer to time certain orders that I will be processing.  I
created the timer form based on a table so that the times would be bound (the
ElapsedTime text box) to it.  I then added two command buttons, one to reset
the timer, and one to start/stop the timer.  I attempted to code it so that
each record would have its own separate timer (before this the timer
continually counted with each record.)The only problem I have is my timer now
counts time very fast and progressively faster as time goes on.  I believe
the problem to be in the private sub form timer portion of my code, but have
had no luck.  I am a beginning coder and need help desperately!!  Here is the
present code.  Please Help!!

Option Compare Database
Option Explicit
Dim TotalElapsedSec As Long
Dim StartTickCount As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub cmdReset_Click()
TotalElapsedSec = 0
   Me!ElapsedTime = "00:00:00"
End Sub

Private Sub cmdStartStop_Click()

If Me.TimerInterval = 0 Then
       StartTickCount = GetTickCount()
       Me.TimerInterval = 30
       Me!cmdStartStop.Caption = "&STOP"
       Me.cmdStartStop.ForeColor = RGB(255, 0, 0)
       Me.cmdStartStop.FontSize = "12"
       Me!cmdReset.Enabled = False
   Else
       TotalElapsedSec = TotalElapsedSec + (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 Form_Timer()
   Dim Hours As String
   Dim Minutes As String
   Dim Seconds As String
   Dim Msg As String
   Dim ElapsedSec As Long
   Dim hour As Long
   Dim minute As Long
   Dim second As Long
   Dim milisec As Long
   Dim temp As String
   hour = Left(Me!ElapsedTime, 2)
   temp = Left(Me!ElapsedTime, 5)
   minute = Right(temp, 2)
   second = Right(Me!ElapsedTime, 2)
   TotalElapsedSec = 3600000 * hour
   TotalElapsedSec = TotalElapsedSec + (60000 * minute)
   TotalElapsedSec = TotalElapsedSec + (second * 1000)
   
   ElapsedSec = (GetTickCount() - StartTickCount) + TotalElapsedSec
   
   Hours = Format((ElapsedSec \ 3600000), "00")
   Minutes = Format((ElapsedSec \ 60000) Mod 60, "00")
   Seconds = Format((ElapsedSec \ 1000) Mod 60, "00")
   
   Me!ElapsedTime = Hours & ":" & Minutes & ":" & Seconds
End Sub
Rick B - 20 Dec 2004 17:54 GMT
Please do not post your question multiple times.  You don't want someone
posting a repose in one group and a separate person working to give you an
answer in another group.  It wastes two (or more) peoples' time.

> I created a timer to time certain orders that I will be processing.  I
> created the timer form based on a table so that the times would be bound (the
[quoted text clipped - 64 lines]
>     Me!ElapsedTime = Hours & ":" & Minutes & ":" & Seconds
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.