How to measure # of charactors for currency fields

G

Guest

I have a currency field and want to get the number of charactors of this
currency field for a text control in the report. For example, if the value of
this Currency field is $52,234.32, I would like have 10 as the number of
charactors. If the value of the Currency field is $28.35, I would like have
5. Would anyone please let me know how you would handle this? Thanks!!!
 
D

Douglas J Steele

I'm unsure as to how you arrived at 10 and 5. Assuming you're counting the
dollar sign, comma and decimal point, the first has 10 characters and the
second has 6.

To calculate that length, use the Format function (with "Currency" as the
format) to convert the value to a string, then use the Len function to
calculate its length:

?Format(52234.32, "Currency")
$52,234.32
?Len(Format(52234.32, "Currency"))
10
?Format(28.35, "Currency")
$28.35
?Len(Format(28.35, "Currency"))
6
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top