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

x
?
Solved

How to trim string in Access

Posted on 2001-09-12
7
Medium Priority
?
333 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
[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
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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 32

Expert Comment

by:Brendt Hess
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:
Brendt Hess earned 200 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

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