Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How extract string of characters to the right of the 1st hyphen

Posted on 2016-09-13
4
Medium Priority
?
63 Views
Last Modified: 2016-09-13
If I have a string of characters that looks like this:

#10 Small - something - something else

And I want to extract in query designer this part of it: (everything to the right of the 1st hyphen not including the space in front of the 1st "something")

something - something else

How can I do this?
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 85
ID: 41796531
Use a combination of Mid and Instr.

What have you tried so far?
0
 

Author Comment

by:SteveL13
ID: 41796536
Right([tblPaper.Description],InStr([tblPaper.Description],"-")-2)

But it isn't even close.
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 total points
ID: 41796554
Mid([tblPaper.Description], InStr([tblPaper.Description], "-") + 2, Len([tblPaper.Description]) - InStr([tblPaper.Description], "-"))
0
 
LVL 22

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 1000 total points
ID: 41796569
in case there may not be a space after the first hyphen, here is a slight modification to what Scott wrote to TRIM instead:
trim(Mid([tblPaper.Description], InStr([tblPaper.Description], "-") +1 ))

Open in new window

also, the 3rd argument, how many characters to get, is optional so I left it out

if you are doing this in a query, create another column to filter for only records having a dash:

field: Description
table: tblPaper
criteria: Like "*-*"

btw, Description is a reserved word

http://allenbrowne.com/AppIssueBadWord.html
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question