Results 1 to 15 of 15
  1. #1
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    zip code formatting

    i have zips that
    12345-


    and
    12345-1234

    The problem is the dash is on the field of the 5 digit zips. So the shortest zip is 6 characters. When putting the data on reports we do not want the dash to show on the 5 digit zips. But do want it do show on the 9 digit zips.

    I am not sure how to code that. I am thinking I need a new field that is created from the original and drop the dash some how.

    All ideas are welcome.
    Thx
    Russ

  2. #2
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    a picture of the data

    added an attachment

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    use newzip:format(zipcode,"00000;00000")

  4. #4
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    Not there yet..

    Weekend - i tried it and it works sometimes but not always, no rhyme or reason.
    See attached.
    Thx Russ

  5. #5
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    That's interesting, it does remove the end hyphen, but it remove some middle hyphen.
    did you get same result in every run?

  6. #6
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    trying different approaches no luck yet

    Always had the same result.

    I tried this it makes sense right?

    usethiszip: IIf(Len([zip]=6),Left([zip],5),[zip])

    The query ran but the output was just\

    #error

    Still fishing for the right combo.
    Rus

  7. #7
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    some tiny mistake in you expression:
    yours:usethiszip: IIf(Len([zip]=6),Left([zip],5),[zip])

    new: usethiszip: IIf(Len([zip])=6,Left([zip],5),[zip])

  8. #8
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    the #error went away but it still fails ramdomly

    See attached.

  9. #9
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Did you get the new zip directly from [employee zip]?
    I am very doubt of that. both the format function and IIf(Len([zip])=6,Left([zip],5),[zip]) were failed in same record.

    you use [zip] in you expression but I saw employee zip in you attached.

  10. #10
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    it is ok..

    in the properties caption there is a name flipper.
    Rus

  11. #11
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I did see IIf(Len([zip])=6,Left([zip],5),[zip]) in your attachment.
    maybe there is some small thing that you ignored. this is a quite simple expression, I don't see any reason to get 6 from len([zip]) for zip="20005-3521".

  12. #12
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    the beat goes on

    R u thinkin that maybe this would be better?

    IIf(Len([zip])>6,[zip],Left([zip],5))

    Rus

  13. #13
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    Still the grtr 6 has a problem the hyphen dropping??

    Sometime the hyphen gets carried forward sometime not?

  14. #14
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    they should be the same

    if you can attach the database with the table and the query, I can take a farther look.

  15. #15
    techexpressinc's Avatar
    techexpressinc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Dec 2008
    Location
    Indiana, USA
    Posts
    151

    Solved!

    IIF(Len(zip)=6, Left(zip,5),IIF(Len(zip)=9,Format(Zip,"@@@@@-@@@@"),Zip))

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

Similar Threads

  1. Conditional Formatting
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-30-2010, 09:31 PM
  2. conditional formatting right(..)
    By bbeernaert in forum Access
    Replies: 3
    Last Post: 08-25-2010, 12:33 AM
  3. Formatting a label
    By swicklund in forum Reports
    Replies: 4
    Last Post: 08-24-2010, 03:27 PM
  4. Formatting formulas
    By katrinanyc926 in forum Queries
    Replies: 2
    Last Post: 08-16-2010, 07:52 AM
  5. Formatting E-mail Using Code
    By graviz in forum Programming
    Replies: 10
    Last Post: 12-10-2009, 10:10 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