Access Trim after Special Character?

Hello Everyone,
I have a table that lists each of our stores like:
01 - StoreName 1
02 - StoreName 2
03 - StoreName 3

Ideally I would like to be able to Trim the name so it would be like:
StoreName 1
StoreName 2
StoreName 3

The field is called StoreName. Can some help me with the appropriate code to use in the Query?

Thanks,
Jester
smart2009Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HainKurtSr. System AnalystCommented:
use

SELECT mid('02 - StoreName 2', 6)
0
käµfm³d 👽Commented:
Could you do it like this?
UPDATE stores
SET storename = MID(storename, INSTR(1, storename, "- "))

Open in new window

0
käµfm³d 👽Commented:
Correction:
UPDATE stores
SET storename = MID(storename, INSTR(1, storename, "- ") + 2)

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

HainKurtSr. System AnalystCommented:
I mean

mid(name,6)

assuming it always first 5 char to be removed
0
smart2009Author Commented:
Sorry I guess I needed to clarify I don't want to change the data in the table I would just like to have it shortend when using it in a Query. Sorry!
0
smart2009Author Commented:
HainKurt, I can't use the 6 Character because once we get to 100 storenames then it becomes 7 and so on.
0
Patrick MatthewsCommented:
A slight tweak to kaufmed's.  It returns an empty string if there is no hyphen:


UPDATE stores
SET storename = Trim(MID(storename, INSTR(1, storename & "-", "-") + 1))

Open in new window

0
Helen FeddemaCommented:
Try this:

SELECT tblStores.StoreName, Mid([StoreName],InStr([StoreName],"_")+6) AS Store
FROM tblStores;

and here is the query in Datasheet view:

Mid-and-Instr-demo.bmp
0
Helen FeddemaCommented:
I see that I had an underscore in the SQL instead of a dash, which is what I intended.  Here it is again:

SELECT tblStores.StoreName, Mid([StoreName],InStr([StoreName],"-")+2) AS Store
FROM tblStores;

(this way there is no extra space in the last item name)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smart2009Author Commented:
This is exactly what I was looking for! THX!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.