Solved

How to trim string in Access

Posted on 2001-09-12
7
311 Views
Last Modified: 2008-03-03
Hello all,

I have a colum in Access looks like this

Name                                                  Id
Angervil, Moliere (PS, APS)                           1
Arocha, Fernando (PS, Contractor, EDF)                2
...

I need to trim the Name colum that only have the last 3 letters.  In this case, are APS and EDF.  Sometimes there are two ","s and sometimes just one.

How can I do this?

Thanks for your help.
0
Comment
Question by:lisaqin
7 Comments
 
LVL 18

Expert Comment

by:nigelrivett
ID: 6477707
You mean you want to get rid of them?

update tbl
set name = left(name,len(name - 6) & ")"
where right(name,6) in (", APD)",", EDF)")
0
 

Author Comment

by:lisaqin
ID: 6477733
Thanks, but this colum contains data has veriable lenght and position.

0
 

Author Comment

by:lisaqin
ID: 6477797
Ok, I guess my question is: How do I find out the position of a charater in a given string?  ie. abcdefgh, the position of d is 4.  Is there a function that I can do that?

Thanks
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 32

Expert Comment

by:bhess1
ID: 6478155
To find the position of a character in a string in Access, use the InStr function, e.g.:

Select InStr("abcdefgh", "d") As DPos

Returns 4

Now, going to your first case, the Right function should work to your advantage:

Select Mid([Name], InStr([Name], ")") - 4,3) As LastEntry
FROM MyTable
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 50 total points
ID: 6478156
Oops - that should be:

Select Mid([Name], InStr([Name], ")") - 3,3) As LastEntry
FROM MyTable
0
 
LVL 10

Expert Comment

by:StephenCairns
ID: 6478466
Hi If you just want to get the last 3 letters within the brackets then you could try either of these.

Mid((Right(RTrim([name]), 4)), 1, 3)

Mid(RTrim([name]), Len(RTrim([name])) - 3, 3)

if there are following spaces the RTrim will remove them
good luck
0
 

Author Comment

by:lisaqin
ID: 6479327
Thank you so much!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

830 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