Code Compatibility

siouxprincess

Registered User.
Local time
Today, 10:10
Joined
Jun 27, 2007
Messages
11
This code worked fine in Access 2003 to convert time into the format 00:00:00, but it is not working in Access 2007. I need help with how to modify this code.

Function ConvertMinutes(minutes As Variant) As String
If IsNull(minutes) Then
ConvertMinutes = "N/A"
Else
Dim dblMinutes As Double

dblMinutes = CDbl(minutes)

Dim hours As Long
Dim min As Long
Dim seconds As Long

hours = Int(dblMinutes / 60)
min = Int(dblMinutes - (hours * 60))
seconds = (dblMinutes - Int(dblMinutes)) * 60

Dim time As String

If hours < 10 Then
time = "0" & CStr(hours)
Else
time = CStr(hours)
End If

If min < 10 Then
time = time & ":" & "0" & CStr(min)
Else
time = time & ":" & CStr(min)
End If

If seconds < 10 Then
time = time & ":" & "0" & CStr(seconds)
Else
time = time & ":" & CStr(seconds)
End If

ConvertMinutes = time
End If
End Function

 
Just tested it in Access 2010 and it worked just fine.

From the immediate window:

?convertminutes(180)
03:00:00

Something else must be going on, perhaps

JR
 
Thank you JANR for testing the code out and boblarson it was the enable setting. :)
 

Users who are viewing this thread

Back
Top Bottom