E
Eb1mom
I am using this function to calculate elapsed time. It
works very well if there are dates entered for date1 and
date2. If no dates or only one date is entered the text box
with formula will show ERROR. Dates are entered many hours
or sometimes days apart and users are confused by Error
message. I realize ERROR is correct because math functions
can not be performed on a null value. Is there any way I
can change error message to read "waiting for date entry"?
The formula in text box is "=getelapsedtime([date2]-[date1])"
This in Module
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
works very well if there are dates entered for date1 and
date2. If no dates or only one date is entered the text box
with formula will show ERROR. Dates are entered many hours
or sometimes days apart and users are confused by Error
message. I realize ERROR is correct because math functions
can not be performed on a null value. Is there any way I
can change error message to read "waiting for date entry"?
The formula in text box is "=getelapsedtime([date2]-[date1])"
This in Module
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