Concatenate and commas

G

GMartin

I have a query with several fields and then a field that concatenates data
from some of them. Is there a way to place a comma between them and only if
there is data? I tried doing "," but that places a comma there regardless of
data and shows on report.
 
B

BruceM

It would have helped had you provided the actual expression you are using.
If you use the plus sign rather than the ampersand as the concatenation
operator, if any part of the expression is null the entire expression will
evaluate to null:
SomeField: [Field1] & (", " + [Field2])
Will produce:
Field1Contents, Field2Contents
if Field 2 contains a value, and will produce:
Field1Contents
if it does not.
 
G

GMartin

Here is what I have
VicInjury: [Injuries] & " " & (", "+[StabWounds]) & " " & (", "+[Unconscious])
& " " & (", "+[Bones]) & " " & (", "+[Bruises]) & " " & (", "+[AnalTearing])
& " " & (", "+[Otherinjury])

When I do my report......this will show all commas if there is nothing in the
fields.
It would have helped had you provided the actual expression you are using.
If you use the plus sign rather than the ampersand as the concatenation
operator, if any part of the expression is null the entire expression will
evaluate to null:
SomeField: [Field1] & (", " + [Field2])
Will produce:
Field1Contents, Field2Contents
if Field 2 contains a value, and will produce:
Field1Contents
if it does not.
I have a query with several fields and then a field that concatenates data
from some of them. Is there a way to place a comma between them and only
if
there is data? I tried doing "," but that places a comma there regardless
of
data and shows on report.
 
G

GMartin

I got it Bruce. Thanks for the quick response. It turned out to be the
field it was concatenating from.
BruceM said:
It would have helped had you provided the actual expression you are using.
If you use the plus sign rather than the ampersand as the concatenation
operator, if any part of the expression is null the entire expression will
evaluate to null:
SomeField: [Field1] & (", " + [Field2])
Will produce:
Field1Contents, Field2Contents
if Field 2 contains a value, and will produce:
Field1Contents
if it does not.
I have a query with several fields and then a field that concatenates data
from some of them. Is there a way to place a comma between them and only
if
there is data? I tried doing "," but that places a comma there regardless
of
data and shows on report.
 
B

BruceM

It's a handy technique. Glad to hear you got it working.

GMartin said:
I got it Bruce. Thanks for the quick response. It turned out to be the
field it was concatenating from.
BruceM said:
It would have helped had you provided the actual expression you are using.
If you use the plus sign rather than the ampersand as the concatenation
operator, if any part of the expression is null the entire expression will
evaluate to null:
SomeField: [Field1] & (", " + [Field2])
Will produce:
Field1Contents, Field2Contents
if Field 2 contains a value, and will produce:
Field1Contents
if it does not.
I have a query with several fields and then a field that concatenates
data
from some of them. Is there a way to place a comma between them and
only
if
there is data? I tried doing "," but that places a comma there
regardless
of
data and shows on report.
 

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