Zip Code Query

K

Kevin D.

I want to do a query based on zip codes but want the query to only consider
the first 5 numbers of the zip code, so if a zip code is entered as
12345-6789, the query would only consider 12345. How can I do this? Any
help would be appreciated.

Kevin D
 
M

Marshall Barton

Kevin said:
I want to do a query based on zip codes but want the query to only consider
the first 5 numbers of the zip code, so if a zip code is entered as
12345-6789, the query would only consider 12345. How can I do this? Any
help would be appreciated.


Use a calculated field

Zip5: Left(zipfield, 5)

Uncheck the Show box and set the criteria to the desired zip
code (e.g. 12345).
 
J

John Spencer

Most efficient would be to use LIKE criterion if you are just searching.

LIKE "12345*"

If you want to display only the first five, then use Marshall's suggestion.

If you need to search and display then use Marshall's suggestion to display
the data and add zipcode field a second time and use the search criteria
I've suggested. Of course, if this involves only a few thousand records
Marshall's method is going to be just as fast (to the human) as any other
method.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
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