Results 1 to 9 of 9
  1. #1
    tylerpickering is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    22

    Add Leading 0 to a Zipcode

    Hi guys--



    I have some data going into my access database from excel that contains zip codes--my issue is that for states with a leading zero, this sometimes gets cut off.

    Ex. zip code 1111 needs to be 01111.

    Is there a way to check the length of the text and add a leading zero if it's only 4? I know in Excel it would be something like =if(len(A1)<5,0&A1,A1), but I'm pretty new to access and I'm not sure where to start with this.

    Thanks in advance!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I would have zip codes in a text field, but try

    Format(FieldName, "00000")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tylerpickering is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    22
    It is being pulled to access as a text field, the problem is in excel; it's being sent to me without the zeroes already

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    So did the function work for you?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    tylerpickering is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    22
    Said it failed because a type conversion failure--is this because my zip code field is set to text?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No, just tested on a text field with numbers in it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    tylerpickering is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    22
    Hmm I'll keep trying

  8. #8
    tylerpickering is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    22
    Ah got it to work, thanks for your help!

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 12-05-2013, 11:48 AM
  2. leading zero problem
    By pmsg in forum Forms
    Replies: 2
    Last Post: 04-04-2012, 10:37 AM
  3. Zipcode Lookup Autofill
    By jgalloway in forum Access
    Replies: 25
    Last Post: 09-20-2011, 06:54 PM
  4. Looking up a zipcode
    By rbw95662 in forum Forms
    Replies: 1
    Last Post: 03-24-2010, 05:07 AM
  5. Leading Zeroes
    By FREEEEEEDOM in forum Access
    Replies: 2
    Last Post: 04-06-2009, 10:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums