473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How do I trim a text string down to the first two words?

I am trying to merge two Db tables in Access 2007. I am working with tables that vary in the detail given for the Scientific names for plants (my only real cross reference that is useable). For example, Table1 lists the Scientific name as "Alnus incana (L.) Moench ssp. tenuifolia (Nutt.) Breitung" while Table2 lists it as "Alnus incana". I am trying to create a field in Table1 with the trimmed Sci Names matching the Table2(i.e., Alnus incana). What function can I use to do this, and how might it be written?

For simplicity's sake we will call the fields "Detailed" in "Table1" and "Simple" in "Table2".

Thanks for any help,

C
Feb 21 '13 #1

✓ answered by Seth Schrock

It would be better to not store the slimmed down version in your table 1 (see Database Normalization). Instead what you can do is create a query that does the calculation for you when you need it and then reference the query instead of the table. To do this, you will use a combination of the Left() and InStr() functions.

Expand|Select|Wrap|Line Numbers
  1. SELECT Left(Detailed, (InStr(InStr(Detailed, " ") + 1, Detailed, " "))-1) As NewField
  2. FROM Table1
This will get everything up to, but not including the second space.

3 1497
Seth Schrock
2,965 Expert 2GB
It would be better to not store the slimmed down version in your table 1 (see Database Normalization). Instead what you can do is create a query that does the calculation for you when you need it and then reference the query instead of the table. To do this, you will use a combination of the Left() and InStr() functions.

Expand|Select|Wrap|Line Numbers
  1. SELECT Left(Detailed, (InStr(InStr(Detailed, " ") + 1, Detailed, " "))-1) As NewField
  2. FROM Table1
This will get everything up to, but not including the second space.
Feb 21 '13 #2
Thanks, Worked Perfectly!

C
Feb 21 '13 #3
Seth Schrock
2,965 Expert 2GB
No problem. Glad to be able to help. If you would please choose post #2 as the best answer, it will help others who are looking for the answer to a similar question.
Feb 21 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: 00steve | last post by:
Hi, I have a group of records that I need to sort by time field. The time field is a text string (should've been a date/time - I know -doh!) I was wondering if anyone knew how to write a query...
9
by: Mosher | last post by:
Hi all, I was wondering if php can parse a text string for certain words and return "true" if that word is found. For example, I have a string like this: $string = "The rain in spain is the same...
2
by: 00steve | last post by:
Hi, I have a group of records that I need to sort by time field. The time field is a text string (should've been a date/time - I know -doh!) I was wondering if anyone knew how to write a query...
5
by: tmb | last post by:
I need to search a folder & sub-folders for key words in ASP files... I can open the files with Notepad and see the text string there... But when I try to navigate to the folder with Windows...
1
by: tHeRoBeRtMiTcHeLL | last post by:
Below is an earlier post to an Excel Group.. ....but I thought that there might be a way to do this in Access by importing data and then creating append and/or update query. I would most certainly...
6
by: larry mckay | last post by:
Hi, Does anyone have any simple text string encryption routines that are easy to implement? I'm trying to prevent users and system administrators from figuring out how I implement things....
25
by: electrixnow | last post by:
in MS VC++ Express I need to know how to get from one comma delimited text string to many strings. from this: main_string = "onE,Two,Three , fouR,five, six " to these: string1 =...
5
by: geotso | last post by:
Here is the scenario: 1. I have a table (tblCalendar) with the following fields: caldID caldDate caldTitle caldInfo nWinW nWinH
6
by: garyusenet | last post by:
Hi i would like to trim a text string. I have a text string called filename I want to display just the file in my label, and not the path. Can someone tell me how I get everything AFTER, the...
4
by: Ahmed, Shakir | last post by:
I need to remove text string from the list of the numbers mentioned below: 080829-7_A 070529-5_c 080824-7_O 070405_6_p The output will be : 080829-7 070529-5
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.