Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Create two calculated fields in a table based on one field entered

I have a table with a field named "Name".  If I enter John Doe in the field I want two calculated fields in the table to populate.  One being "FirstName" and the result of the calculation would be "John".  The other calculated field would be "LastName" and the result would be "Doe".

I've tried these expressions in the FirstName calculated field but get an error.  (all characters up to the first space)

Left([Name],(InStr(1,[Name]," "))-1)
and
Left(Name, Instr(1, Name, " ") - 1)
and
Left(Name,Instr(Name," ")-1)

But then also, what would be the proper expression for the LastName?

But I also think I need to trim any leading spaces before and after "John Doe" in the event one was typed, correct?
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try for a field name t:
trim(left(trim(t), instr(trim(t)," ")-1))
trim(right(trim(t),len(trim(t))-instr(trim(t)," " )))
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial