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

Remove space in Postcode

Status
Not open for further replies.

emergencyplan

Technical User
Aug 19, 2003
34
GB
Hello - I'm pulling my hair out over this!

I have 195,00 postcodes in a database, all have seven characters (including spaces0, however some only have six letters and numbers. e.g MK453EP(no space), LU1 2RS(one space).

I would like to either; add a space to the MK453EP type post code or remove a space from the LU1 2RS postcode. This is to prevent the user having to either enter a space or not when searching for a specific postcode.

Any ideas gratefully recieved,

Thanks,
 
As long as the data is consistent, this is fairly easy to do. I would use this formula in an update query:
To add a space:
IIF(Instr([fieldname]," ")=0, Left([fieldname],3) & " " & Right([fieldname],3), [fieldname])


To remove the space:
IIF(Instr([fieldname]," ")>0, Left([fieldname],3) & Right([fieldname],3)

This will only work well with consistent data that doesn't have any other errant spaces.

Good Luck,
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top