views:

267

answers:

1

I need to display a number (real), ie 1234.567 like "1.234,56" or "1,234.56". I know that I have to use Format() but I can't figure it out.
(It's for a textbox where the 'Control Source' property is set to some number field)

+1  A: 

This should do it:

Format(number, "#,##0.00")

Where the actual separators used depend on the current locale setting.

Tomalak
Since I can't currently find the according MSDN page, here a nice 3rd party documentation of Format(): http://www.apostate.com/vb-format-syntax
Tomalak
Hm... was not so hard to find, after all: http://msdn.microsoft.com/en-us/library/aa262745(VS.60).aspx ... It's just not very helpful, unfortunately.
Tomalak
There is another link that might be helpful. It contains MS ACCESS user defined numeric formats: http://msdn.microsoft.com/en-us/library/4fb56f4y(VS.80).aspx
Joe Suarez
Perfect, that was it.
Tomalak
Sorry for the delay... I am trying to use "#,###.##" in the textbox's Format property but it's not working. Any ideas?
Nick D
Oh, I thought you wanted to use the VBA Format() function. In the Access UI textbox property, the decimal and thousands separators are locale-specific as well. Using "#.##0,00" may be worth a try. In any case this specific format is named "Standard", so putting in the word "Standard" into the property should work as well. Pressing F1 when you are in the "Format" property field fires up the help, which has good guidance to offer as well.
Tomalak
Thanks Tomalak.
Nick D