Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Zip Plus 4 Format
BobS 

14 years ago
I am trying to format the zip code field to display the +4 format but if I use the @@@@@-@@@@ format I get a trailing - for the zip code entries that only have the first 5 digits. I am in the Beginner levels of Access so I am not using any VBA yet. Is there a way to format the zip to display only the 5 digits if that is all that is available and not have the hyphen hanging there?


Reply from Richard Rost:

You can't do this with a simple format or input mask. It's going to involve the IIF and LEN functions. Store the ZIP code in your table without any formatting. You then have either a 5 or 9 digit text value (if you're only dealing with the US). You can then create a calculated query field like this:

NewZIP: IIF(Len(ZIP)=5,Format(ZIP,"@@@@@"),IIF(Len(ZIP)=9,Format(ZIP,"@@@@@-@@@@"),ZIP))

What this says is basically this:

IF the ZIP is 5 digits long, use the format @@@@@
ELSE IF the ZIP is 9 digits long, use the format @@@@@-@@@@
OTHERWISE just display the ZIP unformatted

Now once you have this field built, you can use NewZIP in any forms or reports where you need to see it formatted.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/17/2026 6:21:14 AM. PLT: 0s