I am building a vehicle downtime database that tracks the amount of time a
vehicle is out of service for whatever reason. I have no problem
determining the length of time the vehicle is out f service in a query
calculation, it works just fine. The problem comes in when I try to create
a control that gives me a running total, and then a subtotal for each day
and a grand total at the end of the report.
I would be happy to correspond, ship the database and pay for some
assistance on this project as I am about to pull my hair out on what should
be a very simple project.
Your assistance will be appreciated.
Try the Datediff function to calculate the difference in time intervals. I
have emailed you an example database.
Rgds
Grant van Dongen
Frank Gresh wrote in message <3m2A2.16697$wt4....@news.rdc1.tx.home.com>...
I'll be happy to post the code here with Grant's approval.
'----------------------------------------------
Function GetElapsedTime(dblInterval As Double) As String
'Returns a formatted string showing elapsed time
' dblInterval may be the difference between any two VBA dates.
' The sum or difference between two VBA dates returns an double number,
' where the integer portion is the number of days and the fractional
' portion is the part of one day.
' Function returns correct elpased time up to two billion seconds or
' approximately 68 years. Causes runtime error for ages over 68 years.
'Source:
'INF: Functions for Calculating and Displaying Date/Time Values
'Article ID: Q88657
'Copyright (c) Microsoft Corporation. 1997.
'Variants of this function also appear in Microsoft's NeatCode.mdb and
'in Getz's VBA Developer's Handbook as function FormatInterval.
Dim totalhours As Long
Dim totalminutes As Long
Dim totalseconds As Long
Dim Days As Long
Dim Hours As Long
Dim Minutes As Long
Dim Seconds As Long
Days = Int(CSng(dblInterval))
totalhours = Int(CSng(dblInterval * 24))
totalminutes = Int(CSng(dblInterval * 1440))
totalseconds = Int(CSng(dblInterval * 86400))
Hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60
GetElapsedTime = Days & " Days " & Hours & " Hours " & Minutes & _
" Minutes " & Seconds & " Seconds "
End Function