Is there a way to convert a fraction (i.e., Text string such as "1/5") to a number equivalent (0.20) in Access? This works well in Excel, and if you have a database of recipes which normally would read "1/2" + the measurement, it is not easily read if you use the decimal equivalent, especially on a measurements that do not divide evenly into 1, such as 1/3 (0.3333...). Yet, when creating a grocery list you need to know how much you need.
If not, you can use InStr to find the "/" then use something like Left to split the two sets of numbers and divide them.
Kevin Robertson
@Reply 3 years ago
Are these the results you are looking for (see screenshot)?
Kevin Robertson
@Reply 3 years ago
Kevin Robertson
@Reply 3 years ago
I updated the function to take into consideration values like '1 1/2', '5 2/4' and so on.
Also, Null values are also covered and will return a zero (0).
Public Function FracToDec(Fraction As Variant) As Double
Dim FracArray() As String, SpacePos As Long, WholeNum As Long, MyFrac As String
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Expert 26.