View Full Version : Updating Zip Code field


jrubins
08-10-2009, 09:58 AM
I have a bunch of 5 digit zip codes that were imported into Access and the zip codes that had "0" as the first digit lost that "0" and just became 4 digit zip codes.

I changed the zip code field in the table to a text field with an input mask of "00000/-9999;0;_" but the zip codes that lost their first digit "0"s were unchanged.

Is there some way to run a query to add a "0" to the beginning of any four digit zip codes? Any help would be greatly appreciated.

Kryst51
08-10-2009, 10:02 AM
Check out this.

http://www.access-programmers.co.uk/forums/showthread.php?t=177271&highlight=leading

jrubins
08-10-2009, 10:09 AM
The problem is I can't re-import the data because I don't have access to the zip code file anymore. Also, I've made changes within my database and if I re-import the zip code file, I'll lose all those changes I've made.

Is there some way to add that first "0" to the data I already have imported without having to re-import (some Visual Basic Code or a kind of update query??)?

boblarson
08-10-2009, 10:22 AM
You could use an Update query like this:


UPDATE YourTableNameHere SET ourTableNameHere.ZipCode = "0" & [ZipCode]
WHERE Len([ZipCode])<5;

jrubins
08-10-2009, 10:31 AM
Thanks a lot! That worked perfectly.

boblarson
08-10-2009, 10:33 AM
Great, glad to hear. :)