4 Replies Latest reply on Apr 13, 2009 5:38 AM by Jade

# Calculation formula for Last Name, First Name, Middle Initial. I'm stuck!

### Title

Calculation formula for Last Name, First Name, Middle Initial. I'm stuck!

### Post

I need to write a calculation field formula yielding a text result for last name, first name and middle initial.

My problem is that I need to generate one space between the last letter of the first name and the middle initial.

My formula works fine for last and first name, as follows: Last_First=   Last Name & ", " & First Name. The result I get from my data is Doe, John. So far so good.

But I need to add a middle initial. So I changed the formula to Last_First_Middle= Last Name & ", " & First Name & Middle Initial.  The result I get is Doe, JohnX.  Ask you can see, I need a space between "John" and "X" (where X is the middle initial.)

Is there a text operator for inserting a space into this formula ???   Or any other way to achieve this result ???

• ###### 1. Re: Calculation formula for Last Name, First Name, Middle Initial. I'm stuck!

Hi,

Just add a space between quotation marks:-

Last_First_Middle= Last Name & ", " & First Name & " " & Middle Initial

Please note that this will add an extra space to the end of the text field if the Middle Initial is empty.  If you plan on using this field in a letter or email, this may not look right.  If this is a concern, post back for a more complex calculation.

• ###### 2. Re: Calculation formula for Last Name, First Name, Middle Initial. I'm stuck!

As Jade suggests, you may run into additional spaces where there is no middle name. So I suggest:

Last Name & ", " & First Name & If ( IsEmpty ( Middle Name ); ""; " " & Left (Middle Name; 1) )

This will skip the space if there is no middle name, otherwise, it will add the space and the initial.

Note that I have used a middle name field here rather than what you may have - a calculated middle initial field. Unless you want to use the middle initial separately, it is more efficient to do all this in one step.

• ###### 3. Re: Calculation formula for Last Name, First Name, Middle Initial. I'm stuck!

Or you could even use:

Trim ( Last Name & ", " & First Name & " " & Left (Middle Name; 1) )

Not sure I could argue which is better programming. ;)

• ###### 4. Re: Calculation formula for Last Name, First Name, Middle Initial. I'm stuck!

uLearnIT wrote:

Not sure I could argue which is better programming. ;)

David: Please don't go there or this thread will ramble on for days. :smileytongue::smileywink: