Concatenation

  • Thread starter Thread starter jz
  • Start date Start date
J

jz

I have a table that was imported from Excel that contained
fields Note and Comments. I want to concatenante the 2
together separated by a comma. As you can tell my SQL
skills are lacking and what I can't figure out is how to
add the comma only if Note and Comments are present:
All Comments: IIf(IsNull([Note]),""," " & [Note]) &
[Comments]
 
Hi,

I think what you need is:

All Comments: IIf(IsNull([Note]), IIf(IsNull([Comments]),""," " &
[Comments])," " & [Note] & IIf(IsNull([Comments]), "", ", " & [Comments]))

Watch out for line wrapping
HTH

MFK.
 
And here's a less convoluted way to achieve the same end:

More Notes: " " & [note] & IIf(([note] Is Not Null) And ([comments] Is Not
Null),", ","") & [comments]

a little clearer I hope :-)

MFK.


Michael Keating said:
Hi,

I think what you need is:

All Comments: IIf(IsNull([Note]), IIf(IsNull([Comments]),""," " &
[Comments])," " & [Note] & IIf(IsNull([Comments]), "", ", " & [Comments]))

Watch out for line wrapping
HTH

MFK.


jz said:
I have a table that was imported from Excel that contained
fields Note and Comments. I want to concatenante the 2
together separated by a comma. As you can tell my SQL
skills are lacking and what I can't figure out is how to
add the comma only if Note and Comments are present:
All Comments: IIf(IsNull([Note]),""," " & [Note]) &
[Comments]
 
Back
Top