Store Leading Zeros? (1 Viewer)

LQ

Registered User.
Local time
Today, 20:32
Joined
Apr 5, 2001
Messages
145
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

Registered User.
Local time
Today, 20:32
Joined
Jun 15, 2000
Messages
719
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

Registered User.
Local time
Today, 20:32
Joined
Apr 5, 2001
Messages
145
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

Super Moderator
Staff member
Local time
Today, 15:32
Joined
Feb 19, 2002
Messages
43,297
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.
 

Users who are viewing this thread

Top Bottom