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

Extract letters only from Text Field 1

Status
Not open for further replies.

rickyshah

MIS
Joined
Jun 15, 2005
Messages
8
Location
GB
Hi All

I have Postcode as a text field and need only the first part of the postcode excluding the number (to later help link in with another table), but its a bit tricky as the first letters of a postcode can range from 1-2 characters:

eg:
Present: Desired Result:
W1V 9DE W
BS8 1EY BS
B2 1YR B
CV6 2EL CV
RH11 0PF RH
PA39 6HL PA

Any help would be most appreciated.

Thanks
 
Hi
Maybe:
[tt]ss = "BS8 1EY"
strPC = IIf(IsNumeric(Mid(ss, 2, 1)), Left(ss, 1), Left(ss, 2))[/tt]
 
This seems to have worked, thanks alot!
 
Hi All

The query has got a little trickier, what do I need to do if I need the following output from the postcode field. Basically need to add back the number but drop off any ending with letters

eg:
Present: Desired Result:
W1V 9DE W1
SW1E 1EY SW1
B2 1YR B2
CV6 2EL CV6
RH1A 0PF RH1
PA3B 6HL PA3

Thanks in advance!
 
Will the break point always be a space? If so:
[tt]strPC = Mid(ss, 1, InStr(ss, " "))[/tt]
 
And what about this ?
strPC = Trim(Left(ss, IIf(IsNumeric(Mid(ss, 2, 1), 2, 3)))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV
Very neat, as always. Is there a missing bracket?
strPC = Trim(Left(ss, IIf(IsNumeric(Mid(ss, 2, 1)), 2, 3)))
 
OOps, sorry for the typo. Good catch Remou !
strPC = Trim(Left(ss, IIf(IsNumeric(Mid(ss, 2, 1)[highlight])[/highlight], 2, 3)))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top