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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a space inbetween the postal incode and outcode of a postcode

Status
Not open for further replies.

taboo

Technical User
Jun 5, 2002
2
GB
I have a table of postcodes. All have a field size of 7 and need an extra space between the postal incode (e.g.E7) and the postal outcode (e.g.3LM). Examples of the formats are

E7 3LM (2 spaces)
E17 3LM (1 space)
EC1R3LM (0 spaces)

What is the formula required to add this space?
 
One way is something like the following

SELECT IIf(Len([PC]![Postcode])=7,[PC]![Postcode],IIf(Len([PC]![Postcode])=6,Left([PC]![Postcode],3)+" "+Right([PC]![Postcode],3),IIf(Len([PC]![Postcode])=5,Left([PC]![Postcode],2)+" "+Right([PC]![Postcode],3)))) AS Expr1
FROM Postcodes AS PC;


Hope this helps

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top