Mailmerge Help

F

Fred

I have a program that interfaces with WORD for mailmerges but unfortunately
the program passes a blank as a null instead of a "0" when it comes to
numbers. Here is my example I am hoping someone can help me. I am trying to
add two fields "a" and "b" together but sometimes the "b" value might be
blank and word errors out when it trys to add a value and a blank. I need
help to properly add "a" and "b" when "b" is a null or if it has a number.

I hope someone seems to understand my delima and can help out.

Thansk,

Fred
 
M

macropod

Hi Fred,

You can overcome this with a compound field coded along the lines of:
{QUOTE{SET Val1 {MERGEFIELD Data1}}{SET Val2 {MERGEFIELD Data2}}{=Val1+Val2 \# 0}}

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message.
 
G

Graham Mayor

On a more simple level you could just use a conditional field eg

{={Mergefield a} + {IF {Mergefield b} = "" "0" "{Mergefield b}"}}


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi Graham,

What if Mergefield 'a' can return nul also? The field code I posted deals with both scenarios. To deal with just 'b', one could also
use:
{QUOTE{SET b {MERGEFIELD b}}{={MERGEFIELD a}+b \# 0}}
or even:
{SET b {MERGEFIELD b}}{={MERGEFIELD a}+b \# 0}
which is simpler still!
 
G

Graham Mayor

On a simple level I meant a level that the OP may understand ;) It was said
that only b might be empty, but it would be easy enough to process a in the
same way. I do like your second version :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi Graham,

This approach is certainly more compact than using IF tests. My first post in this thread shows how one could process many nuls
without resorting to a miriad of IF tests, and keeping the ultimate formula intelligible.
 
G

Graham Mayor

Indeed! I wasn't doubting you :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
F

Fred

I am not sure why, but neither post worked. I even used the CTRL + F9 to
create the brackets. I used all the same spaces and verbiage you guys had
used. The wierd thing is, after I saved the document and closed it and went
back into it and did a toggle fields, most of the information was gone except
for the beginning part.

Any ideas? Anything you want me to supply to you to better help solve my
problem?

Thanks,

Fred
 
D

Doug Robbins - Word MVP

The construction in Macropod's initial response works fine here not matter
what the Mergefields return (Null, a number, a character)

Therefore, I believe that you must have made an error in creating the field
construction. If you select the {=+0} and press Alt+F9 is it replaced by
something else?
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

macropod

Hi Fred,

If you use the coding version without the enclosing QUOTE field, you'll get syntax errors until the merge is run. That's because the
second field needs the bookmark from the first field, which won't have been set yet. Wrapping both fields in a QUOTE field ensures
they'r updated together.
 
F

Fred

Macropod,

I have used your syntax line exactly as you had earlier and when the data is
merged, I get the following:

0

Now, if someone is able to get this to work for me, I will gladly pay them,
if it is not too expensive of course. I am not a programmer but I do well in
following directions.

Thanks,

Fred



macropod said:
Hi Fred,

If you use the coding version without the enclosing QUOTE field, you'll get syntax errors until the merge is run. That's because the
second field needs the bookmark from the first field, which won't have been set yet. Wrapping both fields in a QUOTE field ensures
they'r updated together.

--
Cheers
macropod
[MVP - Microsoft Word]


Fred said:
This is what got returned:

!Syntax Error, +

{=+0}
 
F

Fred

Macropod,

Never mind. I am sorry. It was my fault. I guess I need some good glasses
because I was off a little bit on the {{.

You did an awesome job and I thank you very much!!!!!

Thanks,

Fred

macropod said:
Hi Fred,

If you use the coding version without the enclosing QUOTE field, you'll get syntax errors until the merge is run. That's because the
second field needs the bookmark from the first field, which won't have been set yet. Wrapping both fields in a QUOTE field ensures
they'r updated together.

--
Cheers
macropod
[MVP - Microsoft Word]


Fred said:
This is what got returned:

!Syntax Error, +

{=+0}
 

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