View Full Version : Store Leading Zeros?


LQ
05-10-2001, 06:53 AM
I have two fields where I want to have leading zeros entered to make up a fixed number of digits. In the format property of the textbox, I entered in 000000000-0000, which does indeed display the account number on the form with leading zeros (if necessary). How can I store the leading zeros in that field in the underlying field in the table?

Oh, and I wanted to ask whether there is any way to have a format on a text box without actually displaying that format on the form itself? I don't want the user to see all the zeros in the field when they start a new record.

Thanks in advance....



[This message has been edited by LQ (edited 05-10-2001).]

KevinM
05-10-2001, 08:14 AM
The only way to STORE these is to use a text field rather than a Number field.

When you think about it there isn't really such a number that begins with leading zeros (other than zero on it's own).


HTH

LQ
05-10-2001, 08:36 AM
Well, I fiddled with putting the format in both the form and the underlying table, and now the data (leading zeros included) is being stored in the table. However, my form still displays all those zeros from the formatting (before anyone enters data). Is there any way to get rid of these pesky zeros?

Pat Hartman
05-10-2001, 04:21 PM
FYI, the leading zeros are NOT stored in numeric fields. The Format is simply adding them as the field is displayed. EVERY time you want to show this field, you will need to use a Format to force the zeros to be displayed.

You can't have it both ways. Either you use a format that inserts leading zeros or you don't.

If the field is not used in any arithmitic operations including being incremented to obtain the next value, just make it a text field. In the BeforeUpdate event of the field, you can count the number of characters the user entered and return an error message if the length is incorrect.