In ac2003 I have a field in a report that diplays 23.5625 and I need to convert it to read 23 9/16 how do you convert from numbers to a text.
Paste this function into a module:
Public Function DecimalToFrac(DecimalIn) As String
'Convert decimal to Fraction
Dim strWholePart As String
Dim varNumerator As Variant
Dim lngDenominator As Long
Dim intX As Integer
strWholePart = Int(DecimalIn)
intX = InStr([DecimalIn], ".")
If intX = 0 Or IsError(Mid([DecimalIn], intX + 1)) Then
DecimalToFrac = strWholePart
Exit Function
End If
varNumerator = Mid(DecimalIn, InStr(DecimalIn, ".") + 1)
lngDenominator = 1 & String(1 * Len(varNumerator), "0")
Do While lngDenominator Mod 5 = 0 And varNumerator Mod 5 = 0
varNumerator = varNumerator / 5
lngDenominator = lngDenominator / 5
Loop
Do While lngDenominator Mod 2 = 0 And varNumerator Mod 2 = 0
varNumerator = varNumerator / 2
lngDenominator = lngDenominator / 2
Loop
DecimalToFrac = strWholePart & " " & varNumerator & "/" &
lngDenominator
End Function
Call it from a query:
Exp
ecimalToFrac([FieldName])