Removing extra spaces from the middle of a text field

A

Amy E. Baggott

I have a text field on my report that consists of [FirstName]&" "&[MI]&"
"&[LastName]. However, if the person does not have a middle initial, it
comes out with two spaces between the first and last names (e.g. "Fred
Glutz" instead of "Fred Glutz"). Is there any way in Access to remove the
extra spaces in the field result or am I stuck with it?
 
R

Rick B

The "+" will only add if both fields contain a value.

So...

[MI] + " " would only print the space if there was an entry in [MI].

*** I don't think you need the parenthesis in the following. You can try it
without them if you want...

[FirstName] & " " & ([MI] + " ") & [LastName].
 
F

fredg

I have a text field on my report that consists of [FirstName]&" "&[MI]&"
"&[LastName]. However, if the person does not have a middle initial, it
comes out with two spaces between the first and last names (e.g. "Fred
Glutz" instead of "Fred Glutz"). Is there any way in Access to remove the
extra spaces in the field result or am I stuck with it?

Use the following expression instead of your current one:

=[First Name] & (" "+[MI]) & " " & [LastName]
 
A

Amy E. Baggott

Thank you! It worked beautifully!
--
Amy E. Baggott

"I''m going crazy and I''m taking all of you with me!" -- Linda Grayson


Rick B said:
The "+" will only add if both fields contain a value.

So...

[MI] + " " would only print the space if there was an entry in [MI].

*** I don't think you need the parenthesis in the following. You can try it
without them if you want...

[FirstName] & " " & ([MI] + " ") & [LastName].

--
Rick B



Amy E. Baggott said:
I have a text field on my report that consists of [FirstName]&" "&[MI]&"
"&[LastName]. However, if the person does not have a middle initial, it
comes out with two spaces between the first and last names (e.g. "Fred
Glutz" instead of "Fred Glutz"). Is there any way in Access to remove the
extra spaces in the field result or am I stuck with it?
 

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