By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

Postcode stripping

P: n/a
I am trying to isolate the identifying area codes from postcodes and
want to extract the first one or two letters from each postcode. I have
created a query that uses:

SmallPostCode: IIf(Len([PostalCode])>=2,Left$([PostalCode],2),"")

to extract the first two characters of the postcode. But how do I cope
with postcodes that have only one letter before numbers start? (eg G66
3DP as opposed to GU66 3DP). Any help would be most appreciated!

DD

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

dd*****@yahoo.co.uk wrote:
I am trying to isolate the identifying area codes from postcodes and
want to extract the first one or two letters from each postcode. I have created a query that uses:

SmallPostCode: IIf(Len([PostalCode])>=2,Left$([PostalCode],2),"")

to extract the first two characters of the postcode. But how do I cope with postcodes that have only one letter before numbers start? (eg G66 3DP as opposed to GU66 3DP). Any help would be most appreciated!

DD


use IsNumeric() to do it.
use MID to look at the second letter, see if it's numeric, and if it's
not only take the first character.

Nov 13 '05 #2

P: n/a
DFS
dd*****@yahoo.co.uk wrote:
I am trying to isolate the identifying area codes from postcodes and
want to extract the first one or two letters from each postcode. I
have created a query that uses:

SmallPostCode: IIf(Len([PostalCode])>=2,Left$([PostalCode],2),"")

to extract the first two characters of the postcode. But how do I cope
with postcodes that have only one letter before numbers start? (eg G66
3DP as opposed to GU66 3DP). Any help would be most appreciated!
You can look at the total length, including spaces, which looks to be 7 or
8. Or you can use the built-in IsNumeric() function to evaluation the
individual digits.

DD

Nov 13 '05 #3

P: n/a
On 25 Feb 2005 06:31:49 -0800, dd*****@yahoo.co.uk wrote:
I am trying to isolate the identifying area codes from postcodes and
want to extract the first one or two letters from each postcode. I have
created a query that uses:

SmallPostCode: IIf(Len([PostalCode])>=2,Left$([PostalCode],2),"")

to extract the first two characters of the postcode. But how do I cope
with postcodes that have only one letter before numbers start? (eg G66
3DP as opposed to GU66 3DP). Any help would be most appreciated!

DD


If you just want a list of the area codes, try dowloading from
http://www.jibble.org/ukpostcodes/

This also gives coordinates for each code, though as it is an
"unofficial" compilation is may be incomplete
David
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.