I'm sending price and quantity values to a mail merge doc,
and would like to calculate a "price per each" field. The
Price/Qty formula works great when a quantity exists, but
the problem is that there are cases when the quantity (and
the price, for that matter) are equal to zero.
I've wrestled with the "if" statement shown below, but I'm
still getting the 'divide by zero' error when the merge is
run. I'm thinking the division formula is being evaluated
regardless of its place in the "if" statement. Any
suggestions on how to get the field to do the division if
the quantity is not zero, but to get it to suppress or
print "0.0000" when the quantity is zero?
Here's the statement I've been working with:
{ IF Qty2 <> 0 {=Price2/Qty2 \# "#,###,##0.0000"} 0.0000 }
Much thanks in advance,
Justin
Greg Maxey - 08 Jan 2004 23:27 GMT
Justin,
Thanks for the challenge. This one had me stumped for awhile. I tested
using tables cells so I hope this will work with your merge fields. Try:
{IF {=b1} = 0 {=0 \# "''" } {=a1\b1}
Where a1 represents your Price2 mergefield, b1 represents your Qty2
mergefield and the bit following tyeh \# is a double quote, two singel
quotes, and a double qoute.
HTH

Signature
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
To e-mail, edit out the "w...spam" in gmaxey@whamspammvps.org
> I'm sending price and quantity values to a mail merge doc,
> and would like to calculate a "price per each" field. The
[quoted text clipped - 15 lines]
>
> Justin
Greg Maxey - 09 Jan 2004 10:59 GMT
I made this harder than necessary. An IF field (now tested in a merge)
formatted as follows will work:
{ ID { = {MergeField Price2}/{MergeField Qty2}} = "!Zero Divide" "" { =
{MergeField Price2}/{MergeField Qty2}}}

Signature
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
To e-mail, edit out the "w...spam" in gmaxey@whamspammvps.org
> Justin,
>
[quoted text clipped - 29 lines]
>>
>> Justin