Thousand Separator

Brando

Enthusiastic Novice
Local time
Yesterday, 16:52
Joined
Apr 4, 2006
Messages
100
Hello all,

I have a user input form with a text box that stores a number. When the user inputs the number, I'd like it to display the comma separator (e.g. "1234" becomes "1,234". I've tried putting "#,###" and "#,##0." into the format property of the text box, but I still get 1234. I've also searched for answers to this (should be) simple question and found lots of coding solutions that involve functions. That seems like overkill for a simple format. Any suggestions are appreciated.

AB
 
Sub testXComma()
Dim x As Long
x = 1203
Debug.Print Format(x, "#,###")
End Sub

Gives 1,203, so your format seems OK.
Perhaps(Guessing) you have to reassign the value in the text box.

eg Me.txtBox = Format(Me.txtBox, "#,###")


Update:
I just tested adding a Format #,### property to a textbox on an existing form, and it put the appropriate format on existing values.
 
perhaps the datatype for your controlsource is text?
 
The Format property should be applied after the focus moves from the textbox.
 
Thank you all! It was as simple as CJ London suggested. The data type in my table had been set to text. Once this was changed to Number and "#,###" was put in the format property, it worked perfectly.

AB
 

Users who are viewing this thread

Back
Top Bottom