# Software

## General discussion

Locked

### Fraction number format in Access

By ·
How can I get a number to be formatted as a fraction in Access? Is there a add-in for it?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

Collapse -

### Fraction number format in Access

by In reply to Fraction number format in ...

Access does not have a fraction format like Excel's.
I did find this code that will convert a text entered fraction to a decimal number.

=====================================
'This function will convert a fractional number entered as text
' into a numeric variant (you can force the type yourself)
'
'Fractional numbers must be entered as follows:
'
' "5 1/4" or "25-3/8", negative numbers are supported
'
' (c) 1999 by C. Knight
'
Public Function fncCalcFraction(ByVal frac As String) As Variant

Dim posn As Long 'used to find " " or "-"

On Error Resume Next 'Eval ) may cause error

frac = Trim\$(frac) 'strip leading and trailing spaces
posn = InStr frac, " ") 'look for " "

If posn = 0 Then _

If posn > 0 Then 'got one of 'em
If Left\$(frac, 1) = "-" Then 'is number negative?
Mid\$(frac, posn, 1) = "-" 'yes, subtract fractional value
Else
Mid\$(frac, posn, 1) = "+" 'no, add fractional value
End If
End If

'OK, our string now looks like "5+1/4" or "- -1/4", or it was non-numeric
'if so then eval will bomb and fncCalcFraction will return empty

fncCalcFraction = Eval(frac)

End Function

Collapse -

### Fraction number format in Access

by In reply to Fraction number format in ...

Actually I need the opposite, decimal to fraction. Thanks.

## Related Discussions

• 1

• 10

#### Photo cataloguing databases

Stephensonian2020 ·

• 4

#### How to play flash content in Encarta?

ajdzanovicmilos ·

• 3

#### What is marketing automation software and how it useful for your business

rkberiwal123 ·

• 3

#### How to Integrate a SMS API in PHP?

rkberiwal123 ·