Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Postcode woes

Status
Not open for further replies.

emergencyplan

Technical User
Aug 19, 2003
34
GB
Hello,

i have a form where the user enters a post code to search for an address. I am trying to ensure the postcode always has a space between in the incode and outcode.

I have achieved some success when the entire postcode is entered (e.g MK452RS becomes MK45 2RS and NG76AS becomes NG7 6AS), but I have problems when the user enters only part of a postcode e.g. MK452 or MK45 2 and similarly NG76 (NG7 6). The user will always enter at least the incode and the first number of the outcode, if not more.

Does anyone have any ideas how to solve this problem?

Thanks in advance

Laurence
 
Hi Laurence!

I think the easiest way would be to split the ones you can as above and accept any code with a space, other than that throw it back to the user with a message like, "Post code is ambiguous, please re-enter complete code with a space."

hth


Jeff Bridgham
bridgham@purdue.edu
 
I don't know what the code your using is but it would seem to me that if you did something like this it would work:

[tt]
MyPostCodeControl = Left(MyPostCodeControl,3) & " " & Mid(MyPostCodeControl,4,10)[/tt]

Hope that helps!

Joe Miller
joe.miller@flotech.net
 
Joe,

Thanks for the suggestion, however this will not work. I mention that the post varies, e.g. NG7 and MK45. Therefore,taking the third character from the left as you suggest, splits MK45 as MK4 5, which is wrong?

Am I missing the point?

Thanks
 
So if you only want to split when there are six characters, surround my statement with an if/then that checks the Len() of your control, ie:
[tt]
If Len(MyPostCodeControl) = 6 Then
MyPostCodeControl = Left(MyPostCodeControl,3) & " " & Mid(MyPostCodeControl,4,10)
End If
[/tt]



Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top