Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numbers to Text 1

Status
Not open for further replies.

dlmor

MIS
Sep 5, 2001
1
US
How do I convert numbers in a field to its text equivalent in an Access table?
 
Not really sure what you are meaning, but you might look at the CSTR function... Terry M. Hoey
 
Try searching Numword Module, it converts Numeric Currency into Text. or create new Module and put this Code in it.
After doing this just Write
=Numword(fieldname)

fieldname is name of your control.


Option Compare Database
Option Explicit 'Require explicit variable declaration
'This routine (c) 1994 Alan Simpson author of Understanding Access 2.0 by Sybex
'Variables used in NumWord() procedure defined here in Declarations.
Dim EngNum(120) As String
Dim StringNum As String, English As String
Dim NumArr(4) As Integer

Static Function NumWord(ByVal AmountPassed As Currency) As String
Dim i, WorkNum As Integer
If Not EngNum(1) = "One" Then
EngNum(0) = ""
EngNum(1) = "One"
EngNum(2) = "Two"
EngNum(3) = "Three"
EngNum(4) = "Four"
EngNum(5) = "Five"
EngNum(6) = "Six"
EngNum(7) = "Seven"
EngNum(8) = "Eight"
EngNum(9) = "Nine"
EngNum(10) = "Ten"
EngNum(11) = "Eleven"
EngNum(12) = "Twelve"
EngNum(13) = "Thirteen"
EngNum(14) = "Fourteen"
EngNum(15) = "Fifteen"
EngNum(16) = "Sixteen"
EngNum(17) = "Seventeen"
EngNum(18) = "Eighteen"
EngNum(19) = "Nineteen"
EngNum(20) = "Twenty"
EngNum(30) = "Thirty"
EngNum(40) = "Forty"
EngNum(50) = "Fifty"
EngNum(60) = "Sixty"
EngNum(70) = "Seventy"
EngNum(80) = "Eighty"
EngNum(90) = "Ninety"
End If


'** Convert incoming Currency value to a string for parsing.
StringNum = Format$(AmountPassed, "0000000.00")

'** Initialize other variables
English = ""

NumArr(1) = Val(Mid(StringNum, 1, 2))
NumArr(2) = Val(Mid(StringNum, 3, 2))
NumArr(3) = Val(Mid(StringNum, 5, 3))
NumArr(4) = Val(Mid(StringNum, 9, 2))

'** Just in case the check is for less than a buck...
If AmountPassed < 1 Then
English = &quot;Zero&quot;
End If

For i = 1 To 4
WorkNum = NumArr(i)

If (i = 4) And (NumArr(i) > 0) Then _
English = English & &quot; and Paise&quot;


If WorkNum > 99 Then
English = English & &quot; &quot; & EngNum(Int(WorkNum / 100)) & &quot; Hundred&quot;
WorkNum = WorkNum Mod 100
End If
If WorkNum > 19 Then
English = English & &quot; &quot; & EngNum(Int(WorkNum / 10) * 10)
If WorkNum Mod 10 > 0 Then _
English = English & &quot; &quot; & EngNum(WorkNum Mod 10)
Else
If WorkNum > 0 Then _
English = English & &quot; &quot; & EngNum(WorkNum)
End If

If (i = 1) And (NumArr(i) > 0) Then
English = English & &quot; Lac&quot;
Else
If (i = 2) And (NumArr(i) > 0) Then
English = English & &quot; Thousand&quot;
Else
If (i = 4) And (NumArr(i) > 0) Then
English = English
End If
End If
End If
Next i
NumWord = Trim(English)
End Function

Good Luck

 
Once again, I'm troubled by the posting of material which is clearly marked as copyrighted. This is QUITE ILLEGAL. MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Since the ?Poster? has indicated that the CStr function is what they wanted, I will not post the routine which will convert the Value to an &quot;english&quot; string representation of the value, as in 123.45 converted to &quot;One hundred twenty three point four five&quot;

If some one needs this functionality, please start a NEW thread and contact me directly with the thread title.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top