Trim Statements

K

Kim

I would like to have both these expressions to either come
to a blank or a comma and return an the first string "John"

How can I combine these two statements as an expression?

Original Entry in [Names]: "John Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names]," ")-1)

Original Entry in [Names]: "John, Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names],",")-1)
 
B

Bas Cost Budde

Um (air coding),

Left(Names, IIf(instr(names,",")>0, instr(names,","),instr(names," "))-1)

It will fail when both comma and space are absent, of course, as will
you original two formulas.
I would like to have both these expressions to either come
to a blank or a comma and return an the first string "John"

How can I combine these two statements as an expression?

Original Entry in [Names]: "John Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names]," ")-1)

Original Entry in [Names]: "John, Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names],",")-1)
 
K

Kim

Ok, how would I code if I only wanted John to show up.

Say the fields could be:
John, Doe
John
John Doe
How would I code this? I just want the first string and
nothing else

Thanks, Kim

-----Original Message-----
Um (air coding),

Left(Names, IIf(instr(names,",")>0, instr(names,","),instr (names," "))-1)

It will fail when both comma and space are absent, of course, as will
you original two formulas.
I would like to have both these expressions to either come
to a blank or a comma and return an the first string "John"

How can I combine these two statements as an expression?

Original Entry in [Names]: "John Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names]," ")-1)

Original Entry in [Names]: "John, Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names],",")-1)
 
J

John Spencer (MVP)

IIF(Instr(Names," ")>0,LEFT(Names,Instr(Names," ")-1),
Instr(Names,",")>0,LEFT(Names,Instr(Names,",")-1),
Names )
Ok, how would I code if I only wanted John to show up.

Say the fields could be:
John, Doe
John
John Doe
How would I code this? I just want the first string and
nothing else

Thanks, Kim
-----Original Message-----
Um (air coding),

Left(Names, IIf(instr(names,",")>0, instr(names,","),instr (names," "))-1)

It will fail when both comma and space are absent, of course, as will
you original two formulas.
I would like to have both these expressions to either come
to a blank or a comma and return an the first string "John"

How can I combine these two statements as an expression?

Original Entry in [Names]: "John Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names]," ")-1)

Original Entry in [Names]: "John, Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names],",")-1)
 
G

Guest

It says I have too many arguments.
-----Original Message-----
IIF(Instr(Names," ")>0,LEFT(Names,Instr(Names," ")-1),
Instr(Names,",")>0,LEFT(Names,Instr(Names,",")-1),
Names )
Ok, how would I code if I only wanted John to show up.

Say the fields could be:
John, Doe
John
John Doe
How would I code this? I just want the first string and
nothing else

Thanks, Kim
-----Original Message-----
Um (air coding),

Left(Names, IIf(instr(names,",")>0, instr
(names,","),instr
(names," "))-1)
It will fail when both comma and space are absent, of course, as will
you original two formulas.

Kim wrote:

I would like to have both these expressions to either come
to a blank or a comma and return an the first string "John"

How can I combine these two statements as an expression?

Original Entry in [Names]: "John Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names]," ")- 1)

Original Entry in [Names]: "John, Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names],",")- 1)
.
 
J

John Spencer (MVP)

Whoops! Forgot the second IIF.

IIF(Instr(Names," ")>0,LEFT(Names,Instr(Names," ")-1),
IIF(Instr(Names,",")>0,LEFT(Names,Instr(Names,",")-1),
Names ))



It says I have too many arguments.
-----Original Message-----
IIF(Instr(Names," ")>0,LEFT(Names,Instr(Names," ")-1),
Instr(Names,",")>0,LEFT(Names,Instr(Names,",")-1),
Names )
Ok, how would I code if I only wanted John to show up.

Say the fields could be:
John, Doe
John
John Doe
How would I code this? I just want the first string and
nothing else

Thanks, Kim

-----Original Message-----
Um (air coding),

Left(Names, IIf(instr(names,",")>0, instr (names,","),instr
(names," "))-1)

It will fail when both comma and space are absent, of
course, as will
you original two formulas.

Kim wrote:

I would like to have both these expressions to either
come
to a blank or a comma and return an the first
string "John"

How can I combine these two statements as an expression?

Original Entry in [Names]: "John Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names]," ")- 1)

Original Entry in [Names]: "John, Doe"
Returned by Expression: John
Expression: Expr: Left([Names],InStr(1,[Names],",")- 1)
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top