Hide all characters after "hyphen"

S

sonofroy

I have a field with records that are in this order

Location1 - Material Name
Location2 - Material Name
Location3 - Material Name

I would like the query to only return the field with everything after the
hyphen to be removed for example

Location1
Location2
Location3

How can I query this without actually trimming the original values out?

Thanks
 
D

Daryl S

Sonofroy -

Try this (in a query, form, etc.), substituting the right fieldName. The
InStr function will find the first "-" in your field, the Left function will
pull the leftmost characters of the fieldName (the -1 is needed so it doesn't
pull the "-"), and the Trim will remove any extra spaces before and after the
result.

=Trim(Left([fieldName],InStr(1,[fieldName],"-")-1))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top