Postcode Extraction

simon4amiee

Registered User.
Local time
Today, 02:44
Joined
Jan 3, 2007
Messages
109
Hi guys, i sthere a way to extract a postcode when there are double space on some and not others.

SA1 1AB (i need SA1 1AB)
HU1 2AB (i need HU1 2AB)
HU17 0BG (ok)

For some reason the postcode field returns 2 spaces when the postcode length is only 6 digits and 3 spaces when the postcode length is only 5 digits. Im assuming that the postcode field needs to be 8 characters in length (including a space).

All I want to to remove the addition spaces and return a normal looking postcode!
 
Something like

Left(postcode,instr(postcode," ")+1) & right(postcode,3)

Untested

Brian
 
Could you replace the double spaces with a single space?
Code:
Replace(postCode, "  ", " ")
 
Hi Brian,

I was trying to remove some guesswork
Im assuming that the postcode field needs to be 8 characters in length (including a space).

The OP has access to the code, so if it is a restriction with his/her code/design, it should be evident what the length should be.

If the question is what are the standards for UK postal code formats, then here's a reference to work from/with.
 
Ok , I must admit that statement you quote puzzled me.

Brian
 
Something like

Left(postcode,instr(postcode," ")+1) & right(postcode,3)

Untested

Brian

PMFJI but wouldn't Left(postcode,instr(postcode," ")) & right(postcode,3) do the job as you will have located the first space in the field.?
 
Erm! Erm! Can I plead a Senior Moment?

Brian

Ps what does PMFJI stand for if it's pardon me for jumping in then that is always welcome when things need correction or even for another method, nobody has exclusive rights to a thread, but your manners are most welcome .
 
Of course. :D

And yes PMFJI means exactly that.
 
i would definitely strip out multiple spaces to get (hopefully) a valid UK post code.

Code:
 while instr(postcode,"  ")>0 '2 spaces!
     postcode = replace(postcode,"  "," ")
 wend
 

Users who are viewing this thread

Back
Top Bottom