View Full Version : Concatenation and Nulls


Keith Nichols
12-30-2006, 05:20 PM
Hi there,

Chatting with someone who used Excel a lot, I mentiond the method I use in Access to concatenate things without spaces when an item is null. For example:

Expr1: [FName] & " " & ([MName]+" ") & [LName]

The bracketed middle part of the expression will not produce anything if there is no middle name and so avoid having 2 spaces between the first and last name.

I have tried this in Excel and it doesn't work:
=A2&" "&(B2+" ")&C2 which gives a #Name error.

Is there any straightforward way to achieve the same result as I get in Access?

Regards,

shades
01-02-2007, 06:09 AM
Howdy. Try this:

=A2&" "&IF(B2<>"",B2&" "&C2,C2)

Keith Nichols
01-02-2007, 06:30 AM
Is there any straightforward way to achieve the same result as I get in Access?

Howdy. Try this:

=A2&" "&IF(B2<>"",B2&" "&C2,C2)

Pretty straightforward Shades and works a treat.

Regards,