D
Database User
Is there a formula that can automatically look at the firstname field and
work out the initial or initials if there are 2 names?
work out the initial or initials if there are 2 names?
Database User said:Sorry if i'm replying to wrong place i'm not sure where else to apply but
could you please explain - i'm not sure how to write this formula i tried
this but doesn't work
=Left(([Client First Name]))
but tells me that the expression entered has wrong number of arguments.
Could you please write the formula out for a 2 letter initial thanks so
much!
Allen Browne said:Left() grabs the first character.
You could then use Instr() to locate any space, and Mid() to grab the
next
character after the space.
Alternatively, if you want to handle more than 2 names, you could use
Split() to create an array of names, and Left() as you loop through them.
Allen Browne said:You must enter the 2nd argument for Left(), e.g.:
=Left([Client First Name], 1)
You may need to learn more about these functions and VBA in general before
you will be able to parse the following name(s) from the field.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Database User said:Sorry if i'm replying to wrong place i'm not sure where else to apply but
could you please explain - i'm not sure how to write this formula i tried
this but doesn't work
=Left(([Client First Name]))
but tells me that the expression entered has wrong number of arguments.
Could you please write the formula out for a 2 letter initial thanks so
much!
Allen Browne said:Left() grabs the first character.
You could then use Instr() to locate any space, and Mid() to grab the
next
character after the space.
Alternatively, if you want to handle more than 2 names, you could use
Split() to create an array of names, and Left() as you loop through them.
Is there a formula that can automatically look at the firstname field
and
work out the initial or initials if there are 2 names?
Database User said:... could you write me the full thing ...
Is there a formula that can automatically look at the firstname field and
work out the initial or initials if there are 2 names?
John Vinson said:Is there a formula that can automatically look at the firstname field and
work out the initial or initials if there are 2 names?
Hrm. Fun one...
Left([firstname], 1) & IIF(InStr([firstname], " ") > 0,
Mid([Firstname], InStr([firstname], " ")) + 1, 1)
should work assuming a) there are only one or two names and b) there's
only one blank between them.
John W. Vinson[MVP]
Thanks i'm on the right track but with that formula i get the first initial
and a number 1 next to it - what could be the correct formula. I played
around with it a bit but the best i could get was the initial of first name
and then the complete first name i.e. both names =Left([Client First
Name],1) & IIf(InStr([Client First Name]," ")>0," " & Mid([Client First
Name],1))
John Vinson said:Thanks i'm on the right track but with that formula i get the first initial
and a number 1 next to it - what could be the correct formula. I played
around with it a bit but the best i could get was the initial of first name
and then the complete first name i.e. both names =Left([Client First
Name],1) & IIf(InStr([Client First Name]," ")>0," " & Mid([Client First
Name],1))
Just missing part of the expression:
=Left([Client First Name],1) & IIf(InStr([Client First Name]," ")>0,
" ", Mid([Client First Name],InStr([Client First Name]," ")+1, 1))
John W. Vinson[MVP]
I just tried that but it gives me:
Anyone with firstname just one name e.g peter result is PP and anyone who
has 2 names in firstname e.g Peter Henry the result is just P
Can you work it out?!!