Solved How can I get first word from a sentence using Left function? (1 Viewer)

Local time
Today, 09:37
Joined
Aug 19, 2021
Messages
212
Hi, I have an excel formula to get the first word from a sentence.
=LEFT(CellName,FIND(" ",CellName)-1)
Example:
1654608048521.png

I want to use this in Microsoft Access to find the first word from a particular field by using calculation column.
Can anyone guide me how to use this?

Thank you
 

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,239
Assuming Text String is the name of a field :
Code:
Left([Text String], InStr([Text String], " ")-1)
 
Local time
Today, 09:37
Joined
Aug 19, 2021
Messages
212
Assuming Text String is the name of a field :
Code:
Left([Text String], InStr([Text String], " ")-1)
1654666576927.png

Thank you isla, but nn error occurred.
 

isladogs

MVP / VIP
Local time
Today, 05:37
Joined
Jan 14, 2017
Messages
18,239
Don't use a calculated field as that's unnecessary duplication of data.
The expression I gave was intended for use in a query where it will work
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:37
Joined
May 7, 2009
Messages
19,247
you only use it in Query.
also you first Test if there is indeed a Space(" ") character:

Iif(Instr(1, CellName, " ") <> 0, Left(CellName, Instr(1, CellName, " ") - 1), CellName)
 
Local time
Today, 09:37
Joined
Aug 19, 2021
Messages
212
Don't use a calculated field as that's unnecessary duplication of data.
The expression I gave was intended for use in a query where it will work
Thank you so much dear! Now I am using it in a Query & its working. But there is a problem. Actually I want to combine some numerical values from 3 fields and concatenate them to make a numerical field. But its result type is not number. So I can not sort it as (Smallest to Largest).
I have the following fields.
1) AccountGroup
Examples: "1 Current Asset", "2 Fixed Asset", "3 Intangible Asset", "1 Current Liability", "2 Long Term Liability" etc.
2) AccountType
Examples: "1 Asset", "2 Liability", "3 Proprietorship", "4 Revenue", "5 Expense", "6 Stock" etc
3) ID (Autonumber field)
I am using the following code:
Code:
CD: Left([AccountType],InStr([AccountType]," ")-1) & Left([AccountGroup],InStr([AccountGroup]," ")-1) & "." & [ID]

The result is fine like:
1654688086557.png

Can I change its result type to number to sort it as (Smallest to Largest).
 

Minty

AWF VIP
Local time
Today, 05:37
Joined
Jul 26, 2013
Messages
10,371
Use the CDec() function around the whole concatenation

 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:37
Joined
May 7, 2009
Messages
19,247
you can format the ID to "00" so it will sort correctly:

CD: Left([AccountType],InStr([AccountType]," ")-1) & Left([AccountGroup],InStr([AccountGroup]," ")-1) & "." & Format([ID], "00")
 
Local time
Today, 09:37
Joined
Aug 19, 2021
Messages
212
you can format the ID to "00" so it will sort correctly:

CD: Left([AccountType],InStr([AccountType]," ")-1) & Left([AccountGroup],InStr([AccountGroup]," ")-1) & "." & Format([ID], "00")
Thank you so much solved.
 

Minty

AWF VIP
Local time
Today, 05:37
Joined
Jul 26, 2013
Messages
10,371
Simply

CD: CDec(Left([AccountType],InStr([AccountType]," ")-1) & Left([AccountGroup],InStr([AccountGroup]," ")-1) & "." & Format([ID], "00"))
 

Users who are viewing this thread

Top Bottom