Padding with zeros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to replicate two fields in my db and pad them with zeros. For
instance say the old field reads 222, I was a new field to read 000222. Im
really new with access and IM not sure how clear I even made the question.
Any advice or tips would be appreciated.
 
You can use the Format function to do this. If you want to update a new
field then it must be of text data type, not a number data type and you'd
update it in an UPDATE query like so:

UPDATE YourTable
SET NewField = Format(OldField,"000000");

Alternatively you can just keep the field as it is an format it as required
in a SELECT query:

SELECT Format(OldField,"000000") AS NewField
FROM YourTable;

Ken Sheridan
Stafford, England
 
Are the fields number or text? If a number, you can not store leading zeros.
You can display them like that when needed on forms and reports.

Do you wish to pad them out with three 0's always or do you want something
like the total lenght to always be 6 characters?

For the most part, it's seldom a good idea to have more than one field
containing the same data. Better to display the data as and when needed
leaving only one field storing the data.
 
Back
Top