Trimming commas from combined fields

G

Guest

Hi.

If I have the following as a fields control source in a report, is there a
way of stopping the next comma appearing if any supplying field, except the
last one, is empty?

=[AddressLine1]& ", " &[Town]& ", " &[County]& ", " &[PostCode]

e.g if a particular record has no County, I get:

42 Fenchurch St, Wanchester, , ET4 4SA

How do I stop double commas appearing?

Thanks, JohnB
 
D

Duane Hookom

You can generally use + rather than & to remove the comma:

=[AddressLine1]& ", " &[Town]& ", " + [County]& ", " &[PostCode]
 
A

Al Camp

John,
Try this for the Address and Town, and you carry that through with the
other elements...
= [AddressLine1] & IIF(IsNull([Town]), "", ", " & [Town]) &
IIF(IsNull([County])....... etc

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
G

Guest

Thanks Duane. I'll try that. Cheers, JohnB

Duane Hookom said:
You can generally use + rather than & to remove the comma:

=[AddressLine1]& ", " &[Town]& ", " + [County]& ", " &[PostCode]

--
Duane Hookom
MS Access MVP


JohnB said:
Hi.

If I have the following as a fields control source in a report, is there a
way of stopping the next comma appearing if any supplying field, except
the
last one, is empty?

=[AddressLine1]& ", " &[Town]& ", " &[County]& ", " &[PostCode]

e.g if a particular record has no County, I get:

42 Fenchurch St, Wanchester, , ET4 4SA

How do I stop double commas appearing?

Thanks, JohnB
 
G

Guest

Thanks Al. I'll have a look at you sugesstion, along with Duanes. Cheers, JohnB

Al Camp said:
John,
Try this for the Address and Town, and you carry that through with the
other elements...
= [AddressLine1] & IIF(IsNull([Town]), "", ", " & [Town]) &
IIF(IsNull([County])....... etc

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

JohnB said:
Hi.

If I have the following as a fields control source in a report, is there a
way of stopping the next comma appearing if any supplying field, except
the
last one, is empty?

= [AddressLine1] & ", " &[Town]& ", " &[County]& ", " &[PostCode]

e.g if a particular record has no County, I get:

42 Fenchurch St, Wanchester, , ET4 4SA

How do I stop double commas appearing?

Thanks, JohnB
 

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