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

First word of a String

Status
Not open for further replies.

Rachel30

Programmer
Mar 1, 2005
95
GB
Hi,

I have a field called status. in this field I could have string link:-

New
Amendments Only

I only want the first word to show of the string ie:-

New
Amendments

Any idea's how to write an expression for this. Thanks Rachel
 
Hi,
Code:
Left([Field], InStr([Field], " ")-1)


Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Put the string into a variable (strWord in this example).
Then, use
Code:
If InStr(strWord, " ") > 0 Then
   strWord = Left(strWord, InStr(strWord, " "))
End If

If you're doing this in a query, the code would be
Code:
IIf(InStr([FieldName], " ") > 0, Left([FieldName], InStr([FieldName], " ")), [FieldName])

-------------------------
Just call me Captain Awesome.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top