--- In [email protected], "anasbhai" <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I want to convert numeric data such as "1050" to in word ONE THOUSAND
> & FIFTY only . How can I do it in Access 2002.
>
> Thanks in advance
>
> S.Shamael
>
here is code that i use
Function nw(numbertext As Double)
camt = ""
ones = " ONE TWO THREEFOUR FIVE SIX SEVENEIGHTNINE "
TEEN = "TEN ELEVEN TWELVE THIRTEEN FOURTEEN FIFTEEN SIXTEEN
SEVENTEENEIGHTEEN NINETEEN "
tens = "TWENTY THIRTY FORTY FIFTY SIXTY SEVENTYEIGHTY NINETY"
numbertext = Format(numbertext, "000000.00")
xx = Format(numbertext, "000000.00")
nw = Format(numbertext, "000000.00")
numbertext = Format(numbertext, "000000.00")
words1 = Mid(xx, 1, 1)
words2 = Mid(xx, 2, 2)
words3 = Mid(xx, 4, 1)
words4 = Mid(xx, 5, 2)
WORDS6 = Mid(xx, 8, 1)
words7 = Mid(xx, 9, 1)
' THE BELOW IS FOR THE 1ST DIGITI
If words1 <> 0 Then
twords1 = RTrim(Mid(ones, words1 * 5 + 1, 5)) + " HUNDRED "
camt = camt + twords1
Else
twords1 = ""
camt = camt + twords1
End If
' THE BELOW IS FOR 2ND & 3RD DIGIT
If words2 < 10 And words2 > 0 Then
twords2 = RTrim(Mid(ones, words2 * 5 + 1, 5)) + " THOUSAND "
camt = camt + twords2
ElseIf words2 > 9 And words2 < 20 Then
twords2 = RTrim(Mid(TEEN, Right(words2, 1) * 9 + 1, 9)) + " THOUSAND "
camt = camt + twords2
ElseIf words2 > 19 Then
twords2 = RTrim(Mid(tens, Left(words2, 1) * 7 - 13, 7)) ' it is
twenty ok
twords2 = twords2 + "-" + RTrim(Mid(ones, (Right(words2, 1) * 5) +
1, 5)) + " THOUSAND " ' it one ok
camt = camt + twords2
End If
'THE BLOW IS FOR THE 4TH DIGIT
If words3 <> 0 Then
Twords3 = RTrim(Mid(ones, words3 * 5 + 1, 5)) + " HUNDRED "
camt = camt + Twords3
Else
Twords3 = ""
camt = camt + Twords3
End If
'-----------HERE RECORDS FOR 5TH & 6TH DIGITD SAME AS 2ND AND 3RD
If words4 < 10 Then
Twords4 = RTrim(Mid(ones, words4 * 5 + 1, 5))
camt = camt + Twords4
ElseIf words4 > 9 And words4 < 20 Then
Twords4 = RTrim(Mid(TEEN, Right(words4, 1) * 9 + 1, 9))
camt = camt + Twords4
ElseIf words4 > 19 Then
Twords4 = RTrim(Mid(tens, Left(words4, 1) * 7 - 13, 7)) ' it is
twenty ok
Twords4 = Twords4 + "-" + RTrim(Mid(ones, (Right(words4, 1) * 5) +
1, 5)) ' it one ok
camt = camt + Twords4
End If
If Right(xx, 2) > 0 Then
camt = "DOLLARS " + camt + " & CENTS " + Right(Format(numbertext,
"000000.00"), 2) + " ONLY"
ElseIf Right(xx, 2) = 0 Then
camt = "DOLLARS " + camt + " ONLY"
End If
nw = camt
End Function
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ms_access/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/