Using the preceding letters from a UK Postcode

thedawn

Registered User.
Local time
Today, 14:58
Joined
Mar 29, 2010
Messages
30
Hi

I wonder if you could help me - I have a field in a database that is supposed to be a UK postcode. The problem I have is that some people have only supplied the first part i.e. say L1 or LE1 or NG20 and some have supplied the full post code. The data in this field can be from a length of 1 character to a length of 7 characters as i have stripped out the middle space as not all of the entries had this.
Is there a way of detecting whether there is just one letter or two at the front of the postcode and then just stripping the leading letters from the postcode.

Thanks

Rich
 
Probably.

You could check to see if there was a null value (unknown) supplied, using
If isNull(theUKPostCodeField) then "nothing was supplied"--- now what

You should Trim (theUKPostCodeField)
that will remove any leading and/or trailing spaces - no change to internal spaces.

Then find the length of the supplied postal code using
Len(theUKPostCodeField) will return a value representing the length of the value of theUKPostCodeField. Based on what this value is you can now do some processing-- whatever you want to do here.

What exactly do you mean by
whether there is just one letter or two at the front of the postcode and then just stripping the leading letters from the postcode.

Is not the entire text field the UK Postal Code?

see http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
 
why do you want to strip away the first digits??????, that defines the postal area, without that you could have 2 steets with the same suffix but in entrely different areas that would look like the same street in your data.
 
The data in this field can be from a length of 1 character to a length of 7 characters as i have stripped out the middle space as not all of the entries had this.
Rich, see the highlighted part, why do you have this requirement in the first place? Why not have a minimum of 2 letters?
 

Users who are viewing this thread

Back
Top Bottom