Adding preceding zeros to 5 character field

S

SusanS

The original field has 1, 2 or three characters, i.e
1, 12, or 1234. I need to put preceding zeros so it wil
always fill up five spaces, i.e.
00001 or
00012 or
00123

Right now the original field is a whole number field. Do I
need to change it to text. What is the right syntax to
put into an update query. I don't know sql.
 
W

Wayne Morgan

A number field won't store the preceding zeros. There are two options, you
can change the field to text or you can simply format the data to show the
leading zeros when displayed.

If you choose to change the field to a text field, then the update query to
add in the leading zeros would be something like this:

UPDATE Table1 SET Table1.Field1 = Format([Field1],"00000");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top