Solved How can I get first word from a sentence using Left function?

Local time
Today, 12:10
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
 
Assuming Text String is the name of a field :
Code:
Left([Text String], InStr([Text String], " ")-1)
 
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
 
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)
 
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).
 
Use the CDec() function around the whole concatenation

 
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")
 
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.
 
Simply

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

Users who are viewing this thread

Back
Top Bottom