The help site for Microsoft Access


Convert Number to spoken word value

The below link contains a database with one module in it. The module contains various functions, but of note is the function NumberToWords

If you call the following in code NumberToWords(1234543) it will return "One Million Two Hundred and Thirty Four Thousand Five Hundred and Fourty Three"

This function will convert any positive number upto 999,999,999,999, to do negatives just check  before calling this function if the number is negative make it a positive and stick minus in front of it. This is the first release of this function and if you want to recommend a change drop me a line.


Authors Note : If you want to deal with non-integer numbers i.e. 96.54 then replace the main NumberToWords function with the function below

Public Function NumberToWords(OrigNum As Double) As String
    'This function converts numbers to words. For example 101 -> One hundred and one
    'It uses standard English notation and will only accept positive long numbers
    Dim billionpart As Long
    Dim millionpart As Long
    Dim decimalpart As Double
    Dim tmpstr As String
    Dim intpart As Long
    tmpstr = Format$(OrigNum, "0.00")
    tmpstr = Right(tmpstr, Len(tmpstr) - InStr(1, tmpstr, "."))
    decimalpart = CLng(tmpstr)
    intpart = CLng(OrigNum - CDbl("0." & tmpstr))
    'Now int part is correct and decimal
    billionpart = Int(intpart / 1000000000)
    millionpart = intpart Mod 1000000000
    NumberToWords = HundredsToWords(billionpart) & IIf(billionpart <> 0, " billion", "")
    If millionpart > 99 Then
        NumberToWords = NumberToWords & IIf(millionpart <> 0 And billionpart <> 0, " ", "") & millionstowords(millionpart)
        NumberToWords = NumberToWords & IIf(millionpart <> 0 And billionpart <> 0, " and ", "") & millionstowords(millionpart)
    End If
    'Now do decimal part bit
    NumberToWords = NumberToWords & " And " & CStr(decimalpart) & "/" & "100"
End Function
The code and application content of this site is copyright of Smiley I.T. and as such reproduction in any form which is for commercial use requires the permission of the Webmaster. Any use of this code for non-commercial use only requires a link or comment back to the original page you took the code from.