435,269 Members | 1,519 Online
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

# Formatting a Decimal number in Unbound field

 P: n/a I am trying to format a number in an unbound text field using the following format statement in the field's Exit event: txt11UnitWeight = Format(txt11UnitWeight, "00000.00") I want the number to the left of the decimal to be 5 digits long, left zero filled and 2 digits to the right of decimal. Entering a number such as 12345 will get me the required 12345.00. If I have a number such as 1234525, I want the program to format the number as 12345.25, however, what I am getting is 1234525.00. The folling is the code in my KeyPress event that I am using to limit the input: 'Limit input to numbers If (KeyAscii > vbKeySpace And KeyAscii < vbKey0) Or KeyAscii > vbKey9 Then KeyAscii = 0 Else 'Determine if field has a decimal point already (from format stmt) strpos = InStr(txt11UnitWeight.Text, ".") textlen = Len(txt11UnitWeight.Text) If (strpos = 0 And (textlen - txt11UnitWeight.SelLength) = 7) Or _ (strpos > 0 And (textlen - txt11UnitWeight.SelLength = 8)) Then 'allow backspace character If KeyAscii <> 8 Then KeyAscii = 0 End If End If Thanks in advance Stuart Nov 12 '05 #1