IF Statement Hierarchy - Word 2000

C

Chris Stammers

Hello,

Is there a hierarchy in an IF statement? I ask because I have a mailmerge
that is looking at certain criteria to generate a particular letter version
if that criteria is met, so it says { IF { MERGEFIELD field1 } = 2 "{ IF
{MERGEFIELD field2 } = 1 "LETTER" "" }" }

I should say, that within the merge, there are 2 variations of the above,
the other being { IF { MERGEFIELD field1 } = 2 "{ IF {MERGEFIELD field2 } <>
1 "LETTER2" "" }" }

There are then queries within the paragraphs of the letters to determine
what the paragraph should say and various formatting queries. It works - kind
of - but in the first version it also seems to be generating the letter where
the second field ISN'T '1', and dropping out part of one of the paragraphs.
It shouldn't be generating at all! HELP, it's driving me mad! (I hope this
all makes some sort of sense.......)

Thanks,
Chris
 
C

Chris Stammers

Hello,

Please ignore this last question; I have since sorted the problem out.
However, do things like Continuous Breaks and the position the query is
placed in the document have an effect on whether or not a merge will work? I
have a query I got from Peter and Graham to format currency to remove the
decimal point from a pence figure. This is on one document in several places
and works fine, but I have have it in another document where it is only used
once and the document generates with 'Field Calculation Error occurred in
record 1' etc.

Does anyone have any thoughts?

Thanks,
Chris

Thanks,
Chris
 
P

Peter Jamieson

At the moment I can't see anything wrong with either of the IF fields :-(
Personally I would always put the other result in (a "" before the final
"}" ) but I don't think it should make any difference).

But what exactly is in the field where you have put "LETTER" ? Is it
literallyt the word LETTER, a set of fields and text, an INCLUDETEXT, or
what (If you have used an INCLUDETEXT, then there could be a problem)

Peter Jamieson
 
D

Doug Robbins - Word MVP

In the case of { IF { MERGEFIELD field1 } = 2 "{ IF {MERGEFIELD field2 } = 1
"LETTER" "" }" }

field1 would be evaluated and if it equals 2, then Field 2 would be
evaluated. If it equals one, the word "LETTER" would be inserted. If
neither condition is met, nothing would be inserted.

Note, you do not need the quote marks around

{ IF {MERGEFIELD field2 } = 1 "LETTER" "" }

Are you sure that the fields always contain numeric values?

--
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
 
P

Peter Jamieson

However, do things like Continuous Breaks and the position the query is
placed in the document have an effect on whether or not a merge will work?

No, except
a. in the obvious sense that you want the results to be laid out how they
need to be laid out :)
b. putting breaks in the middle of a field name (for example) is probably
not going to work.
once and the document generates with 'Field Calculation Error occurred in
record 1' etc.

Can you see the value of the number that seems to cause the problem?

Peter Jamieson
 
C

Chris Stammers

It is a complete letter. I just put 'LETTER' for ease of explanation (!).
This is now working after a bit of playing about.

Thanks,
Chris
 
P

Peter Jamieson

BTW I would call \#"00p" a "query" - these things are normally called by
other jargon expressions, e.g. "numeric switch" or "numeric picture switch".

Peter Jamieson
 
C

Chris Stammers

There is a mix of fields in the AS400 data source however what I was trying
to get to was IF MERGEFIELD field1 = 2 AND field2 = 1, then insert the
appropriate letter, otherwise don't do anything and move on to the next query
in the document which, if I understand correctly, is what you are saying.
After quite exhaustive testing, this is now working.
 

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