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

All Data in a string before space or "-"

Status
Not open for further replies.

MadMax7

MIS
Feb 17, 2004
62
GB
Hope someone can help i have the following code that returns any data before a space in the name field

Left([Name],InStr([Name] & ' ',' ')-1)

i also have the following code that returns any data before a "-"

Left([Name],InStr([Name] & "_","_")-1)

i was wondering if it would be possible to combine the 2 lines of code so it looks for any data before a space or a "_" hope someone can help
 
Try something like:
Left([Name],InStr(Replace([Name]," ","_") & "_","_")-1)


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top