If cell is < 4 digits add 0's in front of number

chrisjack001

Board Regular
Joined
Feb 26, 2010
Messages
57
I have a field in my Access query that is called RequisitionNbr. The numeric data in this field is not consistent as far as the digits. There are some cells with 1 digit number, 2 digit numbers 3 digit numbers, 4 digit numbers etc. I want to add zeros in front of all cells in that field with < 4 digits. Example if this field has 1 digit number like 3, I want the result to be 0003. If it has 2 digits like 24, I want the result to be 0024. If it has a 3 digit number like 424, I want the result to be 0424. Anything 4 digit and above should just be left alone. How can I put this in a query in access. Thanks for your help
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You posted this to the Excel Questions forum. You probably want to post this in the Access forum.
 
Upvote 0
In Excel, you can use =REPT(0,9-LEN(F2))&FIXED(F2,0,1) to pad a value as a nine digit string. Some of this might help in Access. Replace the F2 cell reference with the source field name.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top