How to add zeros in front of a text field in an access table

calendar_today Asked Jul 19, 2010
thumb_up 9 upvotes
history Updated April 16, 2026

Question posted 2010 · +2 upvotes

I have an access table with a text field. It has alpha numeric values. But i want all values to be minimum 3 digit. so i want to add zeroes in front of all single or two digit values

.

5  must become 005
89 must become 089

how do i write a query to update all values in the table.

thanks tksy

Accepted answer +9 upvotes

The key is to add as many zeros as needed to take the length up to 3.

UPDATE yourTable
SET YourField = LEFT("00", 3-LEN(YourField)) + YourField
WHERE LEN(YourField)<3 AND Len(YourField)>0

Top ms-access Q&A (6)

+9 upvotes ranks this answer #22 out of 55 ms-access solutions on this site .