CountyForZip()

<< Click to Display Table of Contents >>

Navigation:  Available Functions >

CountyForZip()

Syntax

CountyForZip( <CharacterValue>, <NumericValue> )

 

Purpose

Given a specific zip code, this function will return the name of the county associated with the zip code. Normally only one county is associated with a zip code, but if multiple counties are associated with the zip code, a specific associated county code may be fetched by passing the number of the desired associated county as the second parameter. Passing zero for the second parameter will cause the CityForZip() to return the number of counties associated with the given zip code. About twenty percent of zip codes in the United States are associated with multiple counties.

 

Parameters

<CharacterValue> may be the name of any character field, but is usually the Zip field. A character (alpha-numeric) field is used for zip codes since they may contain a dash.

 

<NumericValue> is an optional parameter which specifies which county to return for the given zip code (most zip codes have only one county associated with them). If omitted, the first associated county will be returned. If passed as zero, then a count of the number of counties associated with the given zip code will be returned.

 

Returns

The name of the county associated with the given zip code. Or, if <NumericValue> is zero, the number of counties associated with the given zip code.

 

Usage

This function can be used with custom selections. For example, a custom selection could be written to find all the constituents in a zip code bordering multiple counties, or dedicated to a single county.  

 

Example

The following examples illustrate various results of CountyForZip():

 

CALL

RESULT

CountyForZip( .Zip., 0 ) > 1

True if zip borders multiple counties.

CountyForZip( .Zip., 0 ) = 1

True if zip contained within a single county.

CountyForZip( "83864" )

Bonner

CountyForZip( "83864", 0 )

1

CountyForZip( "83864", 1 )

Bonner