Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] mbrinson@gmail.com is offline
external usenet poster
 
Posts: 1
Default Grouping Nested If Statements

I'm trying to create a conditional form letter that is conditional on
whether or not a field has data.
The desired output is three blocks of text fit onto one page based on
whether or not there is date information for the fields "Date1",
"Date2", or "Date3"

I can get it to work fine if I don't care about leaving blank space on
a page. So, if there is only data for Date1, then it will fill in the
text for the first paragraph and then leave the rest of the page blank
and then move on to the next record on the next page. I'm trying to
save that space and make it move to the next record and place the next
text block immediately after the last one instead of leaving the rest
of the page blank for that record.

So, here's the core of the logic:

I have an if statement that evaluates for three conditions.
If Date1 "" and Date2 = "" and Date3 = "" then EVAL = 1
If Date1 "" and Date2 "" and Date3 = "" then EVAL = 2
If Date1 "" and Date2 "" and Date3 "" then EVAL = 3

Then at the end of each conditional insertion of the text block I set
P1 or P2 or P3 equal to a value that corresponds with the DateX that
has been inserted (1, 2, or 3)

P1 is Paragraph 1 on the page.
P2 is Paragraph 2 on the page.
P3 is Paragraph 3 on the page.

P1 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
P1 = 2 when Paragraph 1 has been filled with the text block
corresponding to Date2 not being blank.
P1 = 3 when Paragraph 1 has been filled with the text block
corresponding to Date3 not being blank.

P2 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
etc..... through P3 = 3.

This, coupled with the value for EVAL provides me with a basis to
determine where exactly each text block has been placed and so know
when the last date has been processed (if there's only 1 then EVAL =
1, if there are 2, EVAL = 2, etc...) for that record. This is
necessary so that the merge document knows when to go to the next
record based on a NextIF { REF go } = 1.

I have all of the logic worked out for the case of EVAL = 1, EVAL = 2,
EVAL = 3 coupled with the different possibilities of combinations of
P1 - P3 values.

In between each of the Paragraph selection blocks there is where I
need to be able to say "NEXTIF {REF go} = 1"


ONE PAGE (MAIN MERGE DOCUMENT)
++++++++++++++++++++++++++++++++
+P1------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P2------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P3------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
++++++++++++++++++++++++++++++++

So, if anyone is still with me at this point, here is my problem:

The logic to figure this out requires grouping nested IF statements.
Here's how it would be in pseudo code:

For the Case of EVAL = 1
IF eval = 1
THEN IF p1 = 1 OR p2 = 1 OR P3 = 1
THEN go = 1
ELSE go = 0
END IF

For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF

For the Case of EVAL = 3
IF eval = 3
THEN IF (p1 = 1 OR p1 = 2 OR P1 = 3) AND (p2 = 1 OR p2 = 2 OR p2 =
3) AND (p3 = 1 OR p3 = 2 OR P3 = 3)
THEN go = 1
ELSE go = 0

I've put this into the nested IF structure for the {IF expression ""
""} structure based on if it's AND then I put the new nested IF in the
first set of parenthesis, and if it's OR then in the second set of
parenthesis. BUT IT DOESN'T WORK.

Any help or ideas for this? Sorry about the long drawn out
explanation. I hope I've got the logic figured out. I've been
banging my head on this one a while.

THANKS!

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Grouping Nested If Statements

I think the basic problem you face is that a Letter merge always inserts a
Next Page section break when it starts processing a new record (after the
first record), unless it got to that record using a NEXT or NEXTIF field.

To avoid that, you have to use a Directory (Catalog) merge which does not
automatically insert any type of break. If you do that, then
a. you have to merge to a new document first
b. you have to ensure that you insert any page/section breaks that you
need, if necessary putting them inside the results of an IF field.

If there is /also/ a problem with your if fields, let's get back to that
after you try the Directory thing.

--
Peter Jamieson
http://tips.pjmsn.me.uk

wrote in message
ups.com...
I'm trying to create a conditional form letter that is conditional on
whether or not a field has data.
The desired output is three blocks of text fit onto one page based on
whether or not there is date information for the fields "Date1",
"Date2", or "Date3"

I can get it to work fine if I don't care about leaving blank space on
a page. So, if there is only data for Date1, then it will fill in the
text for the first paragraph and then leave the rest of the page blank
and then move on to the next record on the next page. I'm trying to
save that space and make it move to the next record and place the next
text block immediately after the last one instead of leaving the rest
of the page blank for that record.

So, here's the core of the logic:

I have an if statement that evaluates for three conditions.
If Date1 "" and Date2 = "" and Date3 = "" then EVAL = 1
If Date1 "" and Date2 "" and Date3 = "" then EVAL = 2
If Date1 "" and Date2 "" and Date3 "" then EVAL = 3

Then at the end of each conditional insertion of the text block I set
P1 or P2 or P3 equal to a value that corresponds with the DateX that
has been inserted (1, 2, or 3)

P1 is Paragraph 1 on the page.
P2 is Paragraph 2 on the page.
P3 is Paragraph 3 on the page.

P1 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
P1 = 2 when Paragraph 1 has been filled with the text block
corresponding to Date2 not being blank.
P1 = 3 when Paragraph 1 has been filled with the text block
corresponding to Date3 not being blank.

P2 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
etc..... through P3 = 3.

This, coupled with the value for EVAL provides me with a basis to
determine where exactly each text block has been placed and so know
when the last date has been processed (if there's only 1 then EVAL =
1, if there are 2, EVAL = 2, etc...) for that record. This is
necessary so that the merge document knows when to go to the next
record based on a NextIF { REF go } = 1.

I have all of the logic worked out for the case of EVAL = 1, EVAL = 2,
EVAL = 3 coupled with the different possibilities of combinations of
P1 - P3 values.

In between each of the Paragraph selection blocks there is where I
need to be able to say "NEXTIF {REF go} = 1"


ONE PAGE (MAIN MERGE DOCUMENT)
++++++++++++++++++++++++++++++++
+P1------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P2------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P3------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
++++++++++++++++++++++++++++++++

So, if anyone is still with me at this point, here is my problem:

The logic to figure this out requires grouping nested IF statements.
Here's how it would be in pseudo code:

For the Case of EVAL = 1
IF eval = 1
THEN IF p1 = 1 OR p2 = 1 OR P3 = 1
THEN go = 1
ELSE go = 0
END IF

For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF

For the Case of EVAL = 3
IF eval = 3
THEN IF (p1 = 1 OR p1 = 2 OR P1 = 3) AND (p2 = 1 OR p2 = 2 OR p2 =
3) AND (p3 = 1 OR p3 = 2 OR P3 = 3)
THEN go = 1
ELSE go = 0

I've put this into the nested IF structure for the {IF expression ""
""} structure based on if it's AND then I put the new nested IF in the
first set of parenthesis, and if it's OR then in the second set of
parenthesis. BUT IT DOESN'T WORK.

Any help or ideas for this? Sorry about the long drawn out
explanation. I hope I've got the logic figured out. I've been
banging my head on this one a while.

THANKS!


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Grouping Nested If Statements

Hi mbrinson,

While you're pondering the Directory (Catalog) merge, here's a bit more to chew on.

For the conditions you posted, the following field construction should do the job:
{If{MERGEFIELD Date1} "" {IF{MERGEFIELD Date2} "" {IF{MERGEFIELD Date3} "" "Paragraph 3" "Paragraph 2"} "Paragraph 1"} ""}

But are you sure you haven't overlooked 5 other possibilities:
If Date1 = "" and Date2 = "" and Date3 = "" then EVAL = ?
If Date1 "" and Date2 = "" and Date3 "" then EVAL = ?
If Date1 = "" and Date2 = "" and Date3 "" then EVAL = ?
If Date1 = "" and Date2 "" and Date3 = "" then EVAL = ?
If Date1 = "" and Date2 "" and Date3 "" then EVAL = ?

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

wrote in message ups.com...
I'm trying to create a conditional form letter that is conditional on
whether or not a field has data.
The desired output is three blocks of text fit onto one page based on
whether or not there is date information for the fields "Date1",
"Date2", or "Date3"

I can get it to work fine if I don't care about leaving blank space on
a page. So, if there is only data for Date1, then it will fill in the
text for the first paragraph and then leave the rest of the page blank
and then move on to the next record on the next page. I'm trying to
save that space and make it move to the next record and place the next
text block immediately after the last one instead of leaving the rest
of the page blank for that record.

So, here's the core of the logic:

I have an if statement that evaluates for three conditions.
If Date1 "" and Date2 = "" and Date3 = "" then EVAL = 1
If Date1 "" and Date2 "" and Date3 = "" then EVAL = 2
If Date1 "" and Date2 "" and Date3 "" then EVAL = 3

Then at the end of each conditional insertion of the text block I set
P1 or P2 or P3 equal to a value that corresponds with the DateX that
has been inserted (1, 2, or 3)

P1 is Paragraph 1 on the page.
P2 is Paragraph 2 on the page.
P3 is Paragraph 3 on the page.

P1 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
P1 = 2 when Paragraph 1 has been filled with the text block
corresponding to Date2 not being blank.
P1 = 3 when Paragraph 1 has been filled with the text block
corresponding to Date3 not being blank.

P2 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
etc..... through P3 = 3.

This, coupled with the value for EVAL provides me with a basis to
determine where exactly each text block has been placed and so know
when the last date has been processed (if there's only 1 then EVAL =
1, if there are 2, EVAL = 2, etc...) for that record. This is
necessary so that the merge document knows when to go to the next
record based on a NextIF { REF go } = 1.

I have all of the logic worked out for the case of EVAL = 1, EVAL = 2,
EVAL = 3 coupled with the different possibilities of combinations of
P1 - P3 values.

In between each of the Paragraph selection blocks there is where I
need to be able to say "NEXTIF {REF go} = 1"


ONE PAGE (MAIN MERGE DOCUMENT)
++++++++++++++++++++++++++++++++
+P1------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P2------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P3------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
++++++++++++++++++++++++++++++++

So, if anyone is still with me at this point, here is my problem:

The logic to figure this out requires grouping nested IF statements.
Here's how it would be in pseudo code:

For the Case of EVAL = 1
IF eval = 1
THEN IF p1 = 1 OR p2 = 1 OR P3 = 1
THEN go = 1
ELSE go = 0
END IF

For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF

For the Case of EVAL = 3
IF eval = 3
THEN IF (p1 = 1 OR p1 = 2 OR P1 = 3) AND (p2 = 1 OR p2 = 2 OR p2 =
3) AND (p3 = 1 OR p3 = 2 OR P3 = 3)
THEN go = 1
ELSE go = 0

I've put this into the nested IF structure for the {IF expression ""
""} structure based on if it's AND then I put the new nested IF in the
first set of parenthesis, and if it's OR then in the second set of
parenthesis. BUT IT DOESN'T WORK.

Any help or ideas for this? Sorry about the long drawn out
explanation. I hope I've got the logic figured out. I've been
banging my head on this one a while.

THANKS!

  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Mike[_8_] Mike[_8_] is offline
external usenet poster
 
Posts: 3
Default Grouping Nested If Statements

On Sep 5, 12:27 am, "Peter Jamieson"
wrote:
I think the basic problem you face is that a Letter merge always inserts a
Next Page section break when it starts processing a new record (after the
first record), unless it got to that record using a NEXT or NEXTIF field.

To avoid that, you have to use a Directory (Catalog) merge which does not
automatically insert any type of break. If you do that, then
a. you have to merge to a new document first
b. you have to ensure that you insert any page/section breaks that you
need, if necessary putting them inside the results of an IF field.

If there is /also/ a problem with your if fields, let's get back to that
after you try the Directory thing.

--
Peter Jamiesonhttp://tips.pjmsn.me.uk

wrote in message

ups.com...

I'm trying to create a conditional form letter that is conditional on
whether or not a field has data.
The desired output is three blocks of text fit onto one page based on
whether or not there is date information for the fields "Date1",
"Date2", or "Date3"


I can get it to work fine if I don't care about leaving blank space on
a page. So, if there is only data for Date1, then it will fill in the
text for the first paragraph and then leave the rest of the page blank
and then move on to the next record on the next page. I'm trying to
save that space and make it move to the next record and place the next
text block immediately after the last one instead of leaving the rest
of the page blank for that record.


So, here's the core of the logic:


I have an if statement that evaluates for three conditions.
If Date1 "" and Date2 = "" and Date3 = "" then EVAL = 1
If Date1 "" and Date2 "" and Date3 = "" then EVAL = 2
If Date1 "" and Date2 "" and Date3 "" then EVAL = 3


Then at the end of each conditional insertion of the text block I set
P1 or P2 or P3 equal to a value that corresponds with the DateX that
has been inserted (1, 2, or 3)


P1 is Paragraph 1 on the page.
P2 is Paragraph 2 on the page.
P3 is Paragraph 3 on the page.


P1 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
P1 = 2 when Paragraph 1 has been filled with the text block
corresponding to Date2 not being blank.
P1 = 3 when Paragraph 1 has been filled with the text block
corresponding to Date3 not being blank.


P2 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
etc..... through P3 = 3.


This, coupled with the value for EVAL provides me with a basis to
determine where exactly each text block has been placed and so know
when the last date has been processed (if there's only 1 then EVAL =
1, if there are 2, EVAL = 2, etc...) for that record. This is
necessary so that the merge document knows when to go to the next
record based on a NextIF { REF go } = 1.


I have all of the logic worked out for the case of EVAL = 1, EVAL = 2,
EVAL = 3 coupled with the different possibilities of combinations of
P1 - P3 values.


In between each of the Paragraph selection blocks there is where I
need to be able to say "NEXTIF {REF go} = 1"


ONE PAGE (MAIN MERGE DOCUMENT)
++++++++++++++++++++++++++++++++
+P1------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P2------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P3------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
++++++++++++++++++++++++++++++++


So, if anyone is still with me at this point, here is my problem:


The logic to figure this out requires grouping nested IF statements.
Here's how it would be in pseudo code:


For the Case of EVAL = 1
IF eval = 1
THEN IF p1 = 1 OR p2 = 1 OR P3 = 1
THEN go = 1
ELSE go = 0
END IF


For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF


For the Case of EVAL = 3
IF eval = 3
THEN IF (p1 = 1 OR p1 = 2 OR P1 = 3) AND (p2 = 1 OR p2 = 2 OR p2 =
3) AND (p3 = 1 OR p3 = 2 OR P3 = 3)
THEN go = 1
ELSE go = 0


I've put this into the nested IF structure for the {IF expression ""
""} structure based on if it's AND then I put the new nested IF in the
first set of parenthesis, and if it's OR then in the second set of
parenthesis. BUT IT DOESN'T WORK.


Any help or ideas for this? Sorry about the long drawn out
explanation. I hope I've got the logic figured out. I've been
banging my head on this one a while.


THANKS!


That was exactly what I needed! Wow, how simple. Could have saved
myself hours in tortuous logical thought
THANK YOU!!!!!

  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Mike[_8_] Mike[_8_] is offline
external usenet poster
 
Posts: 3
Default Grouping Nested If Statements

On Sep 5, 3:55 pm, "macropod" wrote:
Hi mbrinson,

While you're pondering the Directory (Catalog) merge, here's a bit more to chew on.

For the conditions you posted, the following field construction should do the job:
{If{MERGEFIELD Date1} "" {IF{MERGEFIELD Date2} "" {IF{MERGEFIELD Date3} "" "Paragraph 3" "Paragraph 2"} "Paragraph 1"} ""}

But are you sure you haven't overlooked 5 other possibilities:
If Date1 = "" and Date2 = "" and Date3 = "" then EVAL = ?
If Date1 "" and Date2 = "" and Date3 "" then EVAL = ?
If Date1 = "" and Date2 = "" and Date3 "" then EVAL = ?
If Date1 = "" and Date2 "" and Date3 = "" then EVAL = ?
If Date1 = "" and Date2 "" and Date3 "" then EVAL = ?

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

wrote in oglegroups.com...
I'm trying to create a conditional form letter that is conditional on
whether or not a field has data.
The desired output is three blocks of text fit onto one page based on
whether or not there is date information for the fields "Date1",
"Date2", or "Date3"


I can get it to work fine if I don't care about leaving blank space on
a page. So, if there is only data for Date1, then it will fill in the
text for the first paragraph and then leave the rest of the page blank
and then move on to the next record on the next page. I'm trying to
save that space and make it move to the next record and place the next
text block immediately after the last one instead of leaving the rest
of the page blank for that record.


So, here's the core of the logic:


I have an if statement that evaluates for three conditions.
If Date1 "" and Date2 = "" and Date3 = "" then EVAL = 1
If Date1 "" and Date2 "" and Date3 = "" then EVAL = 2
If Date1 "" and Date2 "" and Date3 "" then EVAL = 3


Then at the end of each conditional insertion of the text block I set
P1 or P2 or P3 equal to a value that corresponds with the DateX that
has been inserted (1, 2, or 3)


P1 is Paragraph 1 on the page.
P2 is Paragraph 2 on the page.
P3 is Paragraph 3 on the page.


P1 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
P1 = 2 when Paragraph 1 has been filled with the text block
corresponding to Date2 not being blank.
P1 = 3 when Paragraph 1 has been filled with the text block
corresponding to Date3 not being blank.


P2 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
etc..... through P3 = 3.


This, coupled with the value for EVAL provides me with a basis to
determine where exactly each text block has been placed and so know
when the last date has been processed (if there's only 1 then EVAL =
1, if there are 2, EVAL = 2, etc...) for that record. This is
necessary so that the merge document knows when to go to the next
record based on a NextIF { REF go } = 1.


I have all of the logic worked out for the case of EVAL = 1, EVAL = 2,
EVAL = 3 coupled with the different possibilities of combinations of
P1 - P3 values.


In between each of the Paragraph selection blocks there is where I
need to be able to say "NEXTIF {REF go} = 1"


ONE PAGE (MAIN MERGE DOCUMENT)
++++++++++++++++++++++++++++++++
+P1------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P2------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P3------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
++++++++++++++++++++++++++++++++


So, if anyone is still with me at this point, here is my problem:


The logic to figure this out requires grouping nested IF statements.
Here's how it would be in pseudo code:


For the Case of EVAL = 1
IF eval = 1
THEN IF p1 = 1 OR p2 = 1 OR P3 = 1
THEN go = 1
ELSE go = 0
END IF


For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF


For the Case of EVAL = 3
IF eval = 3
THEN IF (p1 = 1 OR p1 = 2 OR P1 = 3) AND (p2 = 1 OR p2 = 2 OR p2 =
3) AND (p3 = 1 OR p3 = 2 OR P3 = 3)
THEN go = 1
ELSE go = 0


I've put this into the nested IF structure for the {IF expression ""
""} structure based on if it's AND then I put the new nested IF in the
first set of parenthesis, and if it's OR then in the second set of
parenthesis. BUT IT DOESN'T WORK.


Any help or ideas for this? Sorry about the long drawn out
explanation. I hope I've got the logic figured out. I've been
banging my head on this one a while.


THANKS!


Sorry, forgot to mention that just because of the business logic there
will always be a date1. If there is a date2 then there is a date1.
Also if there is a date3, then there is a date2.
Thanks for the IF statement construction. I'm going to try that out
just to see now anyway.
Thanks so much for taking the time to respond. You guys are great!



  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Mike[_8_] Mike[_8_] is offline
external usenet poster
 
Posts: 3
Default Grouping Nested If Statements

On Sep 5, 3:55 pm, "macropod" wrote:
Hi mbrinson,

While you're pondering the Directory (Catalog) merge, here's a bit more to chew on.

For the conditions you posted, the following field construction should do the job:
{If{MERGEFIELD Date1} "" {IF{MERGEFIELD Date2} "" {IF{MERGEFIELD Date3} "" "Paragraph 3" "Paragraph 2"} "Paragraph 1"} ""}

But are you sure you haven't overlooked 5 other possibilities:
If Date1 = "" and Date2 = "" and Date3 = "" then EVAL = ?
If Date1 "" and Date2 = "" and Date3 "" then EVAL = ?
If Date1 = "" and Date2 = "" and Date3 "" then EVAL = ?
If Date1 = "" and Date2 "" and Date3 = "" then EVAL = ?
If Date1 = "" and Date2 "" and Date3 "" then EVAL = ?

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

wrote in oglegroups.com...
I'm trying to create a conditional form letter that is conditional on
whether or not a field has data.
The desired output is three blocks of text fit onto one page based on
whether or not there is date information for the fields "Date1",
"Date2", or "Date3"


I can get it to work fine if I don't care about leaving blank space on
a page. So, if there is only data for Date1, then it will fill in the
text for the first paragraph and then leave the rest of the page blank
and then move on to the next record on the next page. I'm trying to
save that space and make it move to the next record and place the next
text block immediately after the last one instead of leaving the rest
of the page blank for that record.


So, here's the core of the logic:


I have an if statement that evaluates for three conditions.
If Date1 "" and Date2 = "" and Date3 = "" then EVAL = 1
If Date1 "" and Date2 "" and Date3 = "" then EVAL = 2
If Date1 "" and Date2 "" and Date3 "" then EVAL = 3


Then at the end of each conditional insertion of the text block I set
P1 or P2 or P3 equal to a value that corresponds with the DateX that
has been inserted (1, 2, or 3)


P1 is Paragraph 1 on the page.
P2 is Paragraph 2 on the page.
P3 is Paragraph 3 on the page.


P1 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
P1 = 2 when Paragraph 1 has been filled with the text block
corresponding to Date2 not being blank.
P1 = 3 when Paragraph 1 has been filled with the text block
corresponding to Date3 not being blank.


P2 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
etc..... through P3 = 3.


This, coupled with the value for EVAL provides me with a basis to
determine where exactly each text block has been placed and so know
when the last date has been processed (if there's only 1 then EVAL =
1, if there are 2, EVAL = 2, etc...) for that record. This is
necessary so that the merge document knows when to go to the next
record based on a NextIF { REF go } = 1.


I have all of the logic worked out for the case of EVAL = 1, EVAL = 2,
EVAL = 3 coupled with the different possibilities of combinations of
P1 - P3 values.


In between each of the Paragraph selection blocks there is where I
need to be able to say "NEXTIF {REF go} = 1"


ONE PAGE (MAIN MERGE DOCUMENT)
++++++++++++++++++++++++++++++++
+P1------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P2------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P3------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
++++++++++++++++++++++++++++++++


So, if anyone is still with me at this point, here is my problem:


The logic to figure this out requires grouping nested IF statements.
Here's how it would be in pseudo code:


For the Case of EVAL = 1
IF eval = 1
THEN IF p1 = 1 OR p2 = 1 OR P3 = 1
THEN go = 1
ELSE go = 0
END IF


For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF


For the Case of EVAL = 3
IF eval = 3
THEN IF (p1 = 1 OR p1 = 2 OR P1 = 3) AND (p2 = 1 OR p2 = 2 OR p2 =
3) AND (p3 = 1 OR p3 = 2 OR P3 = 3)
THEN go = 1
ELSE go = 0


I've put this into the nested IF structure for the {IF expression ""
""} structure based on if it's AND then I put the new nested IF in the
first set of parenthesis, and if it's OR then in the second set of
parenthesis. BUT IT DOESN'T WORK.


Any help or ideas for this? Sorry about the long drawn out
explanation. I hope I've got the logic figured out. I've been
banging my head on this one a while.


THANKS!


So, any ideas (out of curiosity) on the kind of IF field construction
that would be needed for the last group of logic I posted? I don't
know if it's even possible.
I'm talking about this part:
"For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF"

  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Grouping Nested If Statements

"Mike" wrote in message ups.com...
On Sep 5, 3:55 pm, "macropod" wrote:
Hi mbrinson,

While you're pondering the Directory (Catalog) merge, here's a bit more to chew on.

For the conditions you posted, the following field construction should do the job:
{If{MERGEFIELD Date1} "" {IF{MERGEFIELD Date2} "" {IF{MERGEFIELD Date3} "" "Paragraph 3" "Paragraph 2"} "Paragraph 1"} ""}

But are you sure you haven't overlooked 5 other possibilities:
If Date1 = "" and Date2 = "" and Date3 = "" then EVAL = ?
If Date1 "" and Date2 = "" and Date3 "" then EVAL = ?
If Date1 = "" and Date2 = "" and Date3 "" then EVAL = ?
If Date1 = "" and Date2 "" and Date3 = "" then EVAL = ?
If Date1 = "" and Date2 "" and Date3 "" then EVAL = ?

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

wrote in oglegroups.com...
I'm trying to create a conditional form letter that is conditional on
whether or not a field has data.
The desired output is three blocks of text fit onto one page based on
whether or not there is date information for the fields "Date1",
"Date2", or "Date3"


I can get it to work fine if I don't care about leaving blank space on
a page. So, if there is only data for Date1, then it will fill in the
text for the first paragraph and then leave the rest of the page blank
and then move on to the next record on the next page. I'm trying to
save that space and make it move to the next record and place the next
text block immediately after the last one instead of leaving the rest
of the page blank for that record.


So, here's the core of the logic:


I have an if statement that evaluates for three conditions.
If Date1 "" and Date2 = "" and Date3 = "" then EVAL = 1
If Date1 "" and Date2 "" and Date3 = "" then EVAL = 2
If Date1 "" and Date2 "" and Date3 "" then EVAL = 3


Then at the end of each conditional insertion of the text block I set
P1 or P2 or P3 equal to a value that corresponds with the DateX that
has been inserted (1, 2, or 3)


P1 is Paragraph 1 on the page.
P2 is Paragraph 2 on the page.
P3 is Paragraph 3 on the page.


P1 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
P1 = 2 when Paragraph 1 has been filled with the text block
corresponding to Date2 not being blank.
P1 = 3 when Paragraph 1 has been filled with the text block
corresponding to Date3 not being blank.


P2 = 1 when Paragraph 1 has been filled with the text block
corresponding to Date1 not being blank.
etc..... through P3 = 3.


This, coupled with the value for EVAL provides me with a basis to
determine where exactly each text block has been placed and so know
when the last date has been processed (if there's only 1 then EVAL =
1, if there are 2, EVAL = 2, etc...) for that record. This is
necessary so that the merge document knows when to go to the next
record based on a NextIF { REF go } = 1.


I have all of the logic worked out for the case of EVAL = 1, EVAL = 2,
EVAL = 3 coupled with the different possibilities of combinations of
P1 - P3 values.


In between each of the Paragraph selection blocks there is where I
need to be able to say "NEXTIF {REF go} = 1"


ONE PAGE (MAIN MERGE DOCUMENT)
++++++++++++++++++++++++++++++++
+P1------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P2------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
+==============================+
+P3------------------------------------------------------ +
+ - Block of text1 IF Date1 "" - +
+ ------------------------------------------------------ +
+ - Block of text2 IF Date2 "" - +
+ ------------------------------------------------------ +
+ - Block of text3 IF Date3 "" - +
+ ------------------------------------------------------ +
++++++++++++++++++++++++++++++++


So, if anyone is still with me at this point, here is my problem:


The logic to figure this out requires grouping nested IF statements.
Here's how it would be in pseudo code:


For the Case of EVAL = 1
IF eval = 1
THEN IF p1 = 1 OR p2 = 1 OR P3 = 1
THEN go = 1
ELSE go = 0
END IF


For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF


For the Case of EVAL = 3
IF eval = 3
THEN IF (p1 = 1 OR p1 = 2 OR P1 = 3) AND (p2 = 1 OR p2 = 2 OR p2 =
3) AND (p3 = 1 OR p3 = 2 OR P3 = 3)
THEN go = 1
ELSE go = 0


I've put this into the nested IF structure for the {IF expression ""
""} structure based on if it's AND then I put the new nested IF in the
first set of parenthesis, and if it's OR then in the second set of
parenthesis. BUT IT DOESN'T WORK.


Any help or ideas for this? Sorry about the long drawn out
explanation. I hope I've got the logic figured out. I've been
banging my head on this one a while.


THANKS!


So, any ideas (out of curiosity) on the kind of IF field construction
that would be needed for the last group of logic I posted? I don't
know if it's even possible.
I'm talking about this part:
"For the Case of EVAL = 2 (pX would never be equal to 3 because date3
would be empty in this (eval = 2) case)
IF eval = 2
THEN IF ((p1 = 1 OR p1 = 2) AND (p2 = 1 OR p2 = 2)) OR ((p3 = 1 OR
p3 = 2) AND (p1 = 1 OR p1 = 2)) OR ((p2 = 1 OR p2 = 2) AND (p3 = 1 OR
p3 = 2))
THEN go = 1
ELSE go = 0
END IF"


Hi Mike,

I'm not following what you're trying to do that can't be done with the field construction I posted, or with:
{IF{MERGEFIELD Date3} "" "Paragraph 3" {IF{MERGEFIELD Date2} "" "Paragraph 2" {IF{MERGEFIELD Date1} "" "Paragraph 1"}}}
You can, if you wish, have multiple paragraphs as the mergefield output - even including tables and graphics if needed. You can also
re-use the field construction in multiple places to output different paragraphs. For example, in addition to the above, the same
letter could have:
{IF{MERGEFIELD Date3} "" "Paragraph 4" {IF{MERGEFIELD Date2} "" "Paragraph 5" {IF{MERGEFIELD Date1} "" "Paragraph 6"}}}

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

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
grouping BenT New Users 2 July 30th 07 01:45 AM
If then statements LSivak Mailmerge 1 November 9th 06 12:17 AM
Nested If statements in MS Word 2003 - Help! crun Mailmerge 1 April 12th 06 08:10 AM
Grouping Mary Lee Page Layout 1 June 20th 05 11:16 PM
grouping Susan Microsoft Word Help 1 June 14th 05 08:24 PM


All times are GMT +1. The time now is 02:04 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"