Format for Zip Code

  • Thread starter Thread starter msnews.microsoft.com
  • Start date Start date
M

msnews.microsoft.com

Hello,
I am using a fiels zip code in my table . the format i have chosen is
'xxxxx-xxxx' (at input mask property i have set 00000\-9999;;_), it's workin
fine but i do not want to display dash and last 4 digits if 0. is there any
way to hide dash if there aren't last 4 digits.

please let me know how shud i handle this
thanks
 
msnews.microsoft.com said:
Hello,
I am using a fiels zip code in my table . the format i have chosen is
'xxxxx-xxxx' (at input mask property i have set 00000\-9999;;_), it's workin
fine but i do not want to display dash and last 4 digits if 0. is there any
way to hide dash if there aren't last 4 digits.

please let me know how shud i handle this
thanks
With the Zip code mask you are using,
00000\-9999;;_
there shouldn't be any problem with printing a 5 digit Zip code in an
address with a hyphen as the hyphen is NOT being saved with the data (it
only appears in the control where you are entering the data).
So an address field of
=[City] & ", " & [State] & " " & [Zip]
will show as
Los Angeles, CA 900125698
or
Los Angeles, CA 90012
depending upon whether it is a 5 or 9 digit code.

If you do wish to show the hyphen in a report if the Zip is 9 digits and
not show it if it is 5 digits, then you can use:
=[City] & ", " & [State] & " " & IIf(Len([Zip]) =5, [Zip],Left([Zip],5)
& "-" & Right([Zip],4))

To actually save the Input Mask with the data, use:
00000\-9999;0;_
This will only effect newly input data, not existing data.
See Access help.
 
Back
Top