Trimming Names

G

Guest

I have a form where I enter first names into a field called, FirstNames.
After up-date I would like to trim the first names so that if two names are
entered, e.g. James Todd, only James is the defaulted into the PreferedName
field.

Thanks in advance

Nick
 
F

fredg

I have a form where I enter first names into a field called, FirstNames.
After up-date I would like to trim the first names so that if two names are
entered, e.g. James Todd, only James is the defaulted into the PreferedName
field.

Thanks in advance

Nick

Technically, as control source of an unbound control:
=IIf(InStr([FirstName]," ")>0,Left([FirstName],InStr([FirstName],"
")-1),[FirstName])

The above should not be stored in any table.

Personally, if someone sent me a letter addressed to me using my first
name it would go right into the trash.
There are a lot of people who do not use their first name, or always
use both names, i.e. Arthur Conan Doyle, George Bernard Shaw, etc.
 
O

OldPro

I have a form where I enter first names into a field called, FirstNames.
After up-date I would like to trim the first names so that if two names are
entered, e.g. James Todd, only James is the defaulted into the PreferedName
field.

Thanks in advance

Nick

Look for the space with instr(FirstNames," "). If there is one, then
count the number of characters before the space; instr(FirstNames,"
")-1. Use Mid( ) to extract the first name.

FirstNames=iif(instr(FirstNames," ")>1,mid(FirstNames,
1,instr(FirstNames," ")-1,FirstNames)
 

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