Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

General Date - General Date on a Form

Status
Not open for further replies.

Buckar00B0nzai

Technical User
Jun 17, 2009
50
0
0
US
I currently have a form with a Suspense Date and a Record Entry Date. I am using the following 2 modules to subtract Now() from the Suspense Date in order to keep a timer running on remaining time available.

Module 1
Option Explicit

Function GetElapsedSeconds(interval)

Dim totalhours As Long, totalminutes As Long, totalseconds As _
Long
Dim days As Long, hours As Long, Minutes As Long, Seconds As Long

days = Int(CSng(interval))
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
totalseconds = Int(CSng(interval * 86400))
hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60

GetElapsedSeconds = totalseconds

End Function

Module 2
Option Explicit
'------------------------------------------------------------------
' This function calculates the elapsed time between two values and then
' formats the result in four different ways.
'
' The function accepts interval arguments such as the following:
'
' #5/12/95 6:00:00AM# - #5/11/95 10:00:00PM#
'
'
'
' [End Time]-[Start Time]
'------------------------------------------------------------------
Function GetElapsedTime(interval)

Dim totalhours As Long, totalminutes As Long, totalseconds As _
Long
Dim days As Long, hours As Long, Minutes As Long, Seconds As Long

days = Int(CSng(interval))
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
totalseconds = Int(CSng(interval * 86400))
hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60

GetElapsedTime = days & " Days " & hours & " Hours " & Minutes & _
" Minutes " & Seconds & " Seconds "

End Function

Here is the problem - once you are late (by even 1 minute), the timer shows "-1 Days" rather than "0 Days".

Any ideas?
 
Actually - as soon as th etimer hits "0", the seconds go negative (which is good), but it immediately adds -1 Day, -1 Hour, and -1 Minute.

I'm losing my mind here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top