adding zero's before number

ysfpsu

Registered User.
Local time
Today, 01:20
Joined
Aug 2, 2005
Messages
17
I have a field where a user has to input numbers. This number at most will have 8 digits. Something like 00000001 or 00001234. I want access to show those zero's before the number but I can't do it. Any suggestions.

Thanks,
Yusuf
 
You do this using formatting. In the Format Property on a form type 00000000. This will show your numbers as 8 digits with the leading digits as 0 if they are not present.
 
Neileg
If I am looking to produce a concatonated string of a number of values from a table

e'g
Field 1 10
Field 2 2
Fileld 3 6 as

1000206 will the format as you suggest on the input form save the data in the packed form with the field data type as integer. Would this impact calculations ?.

Interested cos been through this and went to great lengths to add packer characters. The situation was a bit special in that I did also have to use the values in calculations. It was the data and resultant data that had to be put into a 255 char string at specific locations with each "value" having a specific length.

Len
 
I did what Nieleg said but it didn't work. I went to the design view of the form right clicked my field and went to format and put in the 8 zero's Nothing changed.

Yusuf
 
You need to set the fields format in the table design to TEXT if you want the preceeding zeros to "stick". Also set the field size to 8 to prevent the number of digits to exceed eight.
 
Yeah. The format only changes the way the data is presented, not how it is stored. It wasn't clear from your question which was important. If you want the leading zeros stored then you can't do this in a number firld because numbers don't have leading zeros. As ghudson suggests, the text field will do this, but now it's no longer a number. Your choice.

Len, you could do what you want in a text field. There's a function that turns a text field into a number, but I can't remember off the top of my head, and I'm heading for the door home....
 
If the number is of datatype number then the format should work. If the number is actualy a text datatype then it will make no difference but you can just type the number in with leading 0's
 
looks like I was a bit slow there :(

You would need to pack each variable wit the format function.
Some thing like

Cint(Format(field1,"000")&Format(field2,"000")&Format(field3,"000"))

HTh

Peter
 

Users who are viewing this thread

Back
Top Bottom