Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: adding time


Message #1 by "Steve Klein" <Stephen@K...> on Thu, 13 Feb 2003 08:14:14 -0000
Signed StationeryHere is my VBTiime module

Function DecimalHours(dtmtime) As Double


Dim h As Double
Dim m As Double

If IsNull(dtmtime) Then
Exit Function
Else
    h = dtmtime * 24
    DecimalHours = h
End If
End Function


Function timestring(DecimalTime) As String

'created by Rob Strevens and Steve Klein
'September 2001



'Remember this function works on the control not the underlying field
'Be absolutely sure the control and its  control source have different names
'or it won't work

On Error GoTo err_timestring                                'this deals with
nulls

Dim VisibleHours   As Integer
Dim VisibleMinutes As Integer


    VisibleHours = Int(DecimalTime)                          'this gives me
the number of hours
    VisibleMinutes = (DecimalTime - VisibleHours) * 60       'this gives me
the number of minutes


    If VisibleMinutes < 10 Then                              'without this
if clause 3 hrs and 5 minutes shows as 3:5
        timestring = VisibleHours & ":0" & VisibleMinutes    'and not 3:05
    Else
        timestring = VisibleHours & ":" & VisibleMinutes
    End If


exit_timestring:
    Exit Function

err_timestring:
    Resume exit_timestring

End Function


for each record  have an invidible control which is timestring([txtTime])
for the totals hide  [txtTotal] and show timestring([txtTotal])



  Return to Index