SUM of two mergefields with possible null values

B

bronco104

I'm using Word 2007 to mailmerge invoice data from a DBF file. The DBF file
presents two tax fields that we would like to add together and show as one
value on the invoice. My formula for this is:

{ =SUM({ MERGEFIELD TAX },{ MERGEFIELD SECONDTAX}) }

However, we have gift invoices where the DBF file don't give any values for
taxes (null value), so my formula will return a syntax error.

I've tried to add an IF field to trap the null, but I'm new at this sort of
thing:

{ IF SUM({ MERGEFIELD TAX },{ MERGEFIELD SECONDTAX}) = "" "0" "SUM({
MERGEFIELD TAX },{ MERGEFIELD SECONDTAX})"}

All I get with this is the value of { MERGEFIELD TAX }, not the SUM of both.

Any help would be appreciated.
 
M

macropod

Hi bronco,

Try:
{={MERGEFIELD TAX \# 0.00}+{ MERGEFIELD SECONDTAX \# 0.00}}

Cheers
 
B

bronco104 via OfficeKB.com

Thank for the response, macro.
I've been able to add the two mergefields together previously... it's the
potential null values that are the issue here. Whether I use my SUM function
or your suggestion, it works fine until my data file gives a null value. I
then get syntax errors.

I need to add something to handle null values when they crop up... maybe an
IF function?
Hi bronco,

Try:
{={MERGEFIELD TAX \# 0.00}+{ MERGEFIELD SECONDTAX \# 0.00}}

Cheers
I'm using Word 2007 to mailmerge invoice data from a DBF file. The DBF file
presents two tax fields that we would like to add together and show as one
[quoted text clipped - 14 lines]
Any help would be appreciated.
 
M

macropod

Hi bronco,

In that case, try:
{={IF{MERGEFIELD TAX}= "" 0 {MERGEFIELD TAX}}+{IF{MERGEFIELD SECONDTAX}= "" 0 {MERGEFIELD SECONDTAX}}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

bronco104 via OfficeKB.com said:
Thank for the response, macro.
I've been able to add the two mergefields together previously... it's the
potential null values that are the issue here. Whether I use my SUM function
or your suggestion, it works fine until my data file gives a null value. I
then get syntax errors.

I need to add something to handle null values when they crop up... maybe an
IF function?
Hi bronco,

Try:
{={MERGEFIELD TAX \# 0.00}+{ MERGEFIELD SECONDTAX \# 0.00}}

Cheers
I'm using Word 2007 to mailmerge invoice data from a DBF file. The DBF file
presents two tax fields that we would like to add together and show as one
[quoted text clipped - 14 lines]
Any help would be appreciated.
 
B

bronco104 via OfficeKB.com

Macro,
That got it. Thanks for your help!
Hi bronco,

In that case, try:
{={IF{MERGEFIELD TAX}= "" 0 {MERGEFIELD TAX}}+{IF{MERGEFIELD SECONDTAX}= "" 0 {MERGEFIELD SECONDTAX}}}

Cheers
Thank for the response, macro.
I've been able to add the two mergefields together previously... it's the
[quoted text clipped - 16 lines]
 

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