Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Zip Code Formatting in Report 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How can I conditionally format the zip code on my mailing labels?

If (there are 9 digits AND the last four are not 0000)
{ then Format = xxxxx-xxxx
} else {Format = xxxxx}

Any solutions?

Access 2000, labels are based on a query.

ck

 
Try out this as a control source and make sure the control is not named the same as your ZipCode field!

=IIf(Len([ZipCode])=5,Format([ZipCode],"00000"),Format([ZipCode],"00000-0000")) Joe Miller
joe.miller@flotech.net
 
Joe, That really clued me in to where to start to control this, but you left off one part that I can't solve (I've been trying for hours) can you build into that statement the ability to format the zip to 5 characters if the last 4 are zeroes? I can't get it.

ck
 
How about this?

=IIf(Len([ZipCode])=5 OR Right([ZipCode],4)="0000",Format([ZipCode],"00000"),Format([ZipCode],"00000-0000"))

HTH Joe Miller
joe.miller@flotech.net
 
It choked on that syntax. Missing ),] or vertical bar. I don't see that missing. Are you sure that is how you insert an OR into the mix? I couldn't figure it out. Does the vertical bar do OR in this context?

ck
 
Ok, I tested this one and it works for me.

= IIf(Len([ZipCode]) = 5 Or Right([ZipCode], 4) = "0000", Format(Left([ZipCode], 5), "00000"), Format([ZipCode], "00000-0000")) Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top