Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding leading zeros 1

Status
Not open for further replies.

piovesan

Technical User
Jan 23, 2002
159
CA
Hi all;

I have imported a table from excel into Access. This table has a field called PID that "should always be" an 8 digit "text" field. Currently some of the data in that field is correct, however I also have some records that have only 5 and 6 digits. For these records, I need to add the "leading" "zeros" to make them 8 digits..... any ideas?

Thanks!!
 
Oops!! Sorry, never mind....I found the answer in another post by:

mstrmage1768 (Programmer) 6 May 02 9:34
In the format property in the table, just put 8 0s.....00000000. This will place any lead zeros necessary to make 8 places.


Very simple and helpful!! Thanks!!!

 
Changing the format will not change the data and may cause confusion. If you want to change a value like "1234" to "00001234" then use an update query like:
Code:
UPDATE tblYourtable
SET [YourField] = Right("00000000" & [YourField],8);

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top