Zip codes

L

LG

I have a zip code field and need to make sure the processor enters at least 5
digits. They can either enter 12345 or 12345-0160 but atleast 5. How would
I go about this?
Thanks
 
J

John Spencer

You can set the validation rule to
Like "#####" Or Like "#####[-]####" OR Is Null

Or (assuming data entry via a form) you can test the value in the control's
Before update event using some VBA like the following untested code

If NOT(Me.ZIPCODE Like "#####" _
OR Me.ZIPCODE LIKE "#####[-]####" _
OR IsNull(Me.ZipCode)) Then
MsgBox "Hey! Enter a valid zip code or blank",,"BAD BAD BAD"
Cancel = True
End If

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top