I saw many program they key-in the amount (example : $1,200.00) and it automatically changed it to wording (as example said : One Thousand Two Hundred Only) report.
How to do that ? thanks.
I saw many program they key-in the amount (example : $1,200.00) and it automatically changed it to wording (as example said : One Thousand Two Hundred Only) report.
How to do that ? thanks.
Public Function Currency_2_String(Amount As Double) As String
Dim dollars As Long
Dim cents As Long
Dim cs As Variant
dollars = Int(Amount)
cents = (Amount - dollars) * 100
cs = Trim(Number_2_String(dollars, "")) + (" and " & Format(cents, "00") & "/100")
Currency_2_String = UCase(Left(cs, 1)) & Mid(cs, 2)
End Function
Public Function Number_2_String(num As Long, Optional units As String = "units") As String
Dim i As Integer
suffix = Array("", "thousand", "million", "milliard", "Tera", "Peta", "Exa")
digitName = Array("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
namety = Array("twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
suffix(0) = units
i = 0
If num = 0 Then
Number_2_String = "and 00/100"
Else
Do Until num = 0
Number_2_String = Small_Number_2_String(num Mod 1000, i) + " " + suffix(i) + " " + Number_2_String
i = i + 1
num = num \ 1000
Loop
End If
End Function
Thanks for the code you given, actually i am very new to MS Access and newbie to programming.![]()
I had try to put the code into the code builder, but nothing happen :shock: , can you please explain how its work ? :?: :roll:
thanks a lot ~~~
?? :cry:Originally Posted by Maxzs
Thanks for the code you given, actually i am very new to MS Access and newbie to programming.![]()
I had try to put the code into the code builder, but nothing happen :shock: , can you please explain how its work ? :?: :roll:
thanks a lot ~~~
Put the code in a module.
Then use the Currency_2_String function as the control source for the text box on the form or report you want to print the currency amount on.
For example:
=Currency_2_String(115.87)
Or, if you are referening a field from a record source for the form or report:
=Currency_2_String(MyAmount)
You could also put it directly into a query that would be the record source:
CurrText: Currency_2_String([MyTable].[MyAmount])
Thanks for your clearly explanation, but there will be two module!
I had tried to put the value into Currency_2_String but nothing happen ....
Could it be my table setting problem ? and how about the number_2_string ?
thanks a lot.
anyone thanks~~
:!: :!: :!: STILL CANT SOLVE IT :!: :!: :!:
Post your database as a zip file and I'll set it up for you.
Cant pm you.. can you give me your email address.
can help on the said problem~~~