Format Zip Code Field in Report to remove dash if there is only 5 numbers versus 9

Posted on 2006-07-12
Last Modified: 2010-03-22
How can I format a zip code field in an access report so if the zip code field only has 5 numbers it will print just the five numbers and not have a dash after the 5 numbers.

For example, on my report the zip code is showing as 12345- and I only want it to show 12345.
Question by:anctech
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 65

Expert Comment

ID: 17094722
u could try this

REPLACE([zip code],"-","")

put this in your query for the report, instead of just reporting on [zip code]

Assisted Solution

BPeb earned 250 total points
ID: 17094926
Or put this in your control source for the field:

=IIF(Len([zip code])>6, [zipcode], Right$([zipcode],5))
LVL 22

Accepted Solution

Flyster earned 250 total points
ID: 17095388
BPeb, shouldn't it be:

=IIF(Len([zip code])>6, [zipcode], Left$([zipcode],5))

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.


Expert Comment

ID: 17095783
Yep, it was the idea that was important! Thanks
LVL 44

Expert Comment

ID: 17096123
My boss used to tell tell me: "That wasn't an idea - that's just something that won't work!  Don't give me ideas - Give me solutions!"  -  never forget it



Expert Comment

ID: 17099996
That's great if the boss never wants to know the genisis of an solution.  I've known some like that, but they tend to be the kind that don't want to be bothered by technical details.

Ideas are are the building blocks of solutions.  I'd take a glimpse (clue) of an idea that's fully formed with the assistance of others over having to go figure it out before presenting it.  I think EE is a great place to get ideas to be used dirrectly on a given problem and indirectly on others that might be close.  This process is also called group brainstorming.  Thus I appreciate Flysters correction to the idea.

Author Comment

ID: 17100079
I appreciate everyones help with this.  I am thinking that it would be fair to split out the points on this to both BPeb and to Flyster being that I actually used info from both of their postings.  Thank you both for your help.
LVL 22

Expert Comment

ID: 17101071
Anctec - Thanks for the points. BPeb - Glad to share the idea. :-)

Expert Comment

ID: 17103075
Me too :)

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question