If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
"AND" (compound conditions)
(version: Word 2003)
I hope someone can help me with this problem, it is driving me crazy: I have these fields in my document: (The /* comments */ are added for clarity here.) { IF { MERGEFIELD "associations" } = "070" { SET v070 true } { SET v070 false } } { NEXTIF v070 } /* as the first record has associations=070, this results in v070 being set to true and Word going to the next data record */ v070: { v070 } /* shows v070 for debugging - true as expected */ less: { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false} /* this should be true, because 1 is less than 3 */ { SET more { = AND (v070; { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false}) } } /* here is the trouble */ mo { more } /* this should be 1, as true and true results in true - but it is not working */ { IF v070 "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"} /* shows 1/3 as expected */ The relevant columns of the first four rows of data a associations; Total_070; Index_070; 070; ; ; ; 3; 1; ; 3; 2; ; 3; 3; (I.e. for the first record associations=070 and the total and index are empty, for the other records associations is empty, total is always 3 and index is counted from 1 to 3. The part I show above only uses the first two records.) The shown result is: v070: true less: true mo 0 1/3 Why is the result of the AND field 0, even though both parts are true?! I don't get it. What is wrong? Am I using AND incorrectly? I have tested { = AND (true; 1) } and different combinations of true, false, 0, and 1 in the brackets after AND - the result was always as expected, e.g. = AND (true; 1) yields 1. Any ideas? Different, not so important question: I think { = AND (v070; { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } ) } should be working, too, instead of { = AND (v070; { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false}) } . Any ideas why it does not work at all? I get a "!Syntax Error, ". I have another weird problem with the same mail merge document: 1. When I open it and preview for the first time (with the first data record, or actually with the first two as I use nextif), the result is true, true, 0, 1/3 as shown above, so as expected except for the weird 0. 2. When I highlight all and press F9, suddenly true, false, 0, / are displayed. How is that possible?! 3. When I click to preview the next record and back to #1, it now shows true, true, 0, 1/3 again. (At least I have found this workaround finally, so I don't have to close and reopen my document all the time.) I first thought, maybe Word now (after the second step, i.e. after pressing F9) is at the second data record and evaluating that one - but in that case, v070 should be false (which remains true) and the "less" statement should still be true, as 23, and not without any reason become false. Help particularly with the first problem would be greatly appreciated. Regards, Monika. |
#2
|
|||
|
|||
It is becoming even weirder. I have changed the fields a
little and copied it five times: { IF { MERGEFIELD "associations" } = "070" { SET v070 true } { SET v070 false } } { NEXTIF v070 } v070: { v070 } 1. { SET less { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false} }{ SET more { = AND (v070; less) } } mo { more } { IF more "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"} { NEXTIF more } 2. { SET less { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false} }{ SET more { = AND (v070; less) } } mo { more } { IF more "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"} { NEXTIF more } 3. { SET less { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false} }{ SET more { = AND (v070; less) } } mo { more } { IF more "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"} { NEXTIF more } 4. { SET less { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false} }{ SET more { = AND (v070; less) } } mo { more } { IF more "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"} { NEXTIF more } 5. { SET less { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false} }{ SET more { = AND (v070; less) } } mo { more } { IF more "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"} { NEXTIF more } The result shown is: v070: true 1. mo 0 1/3 2. mo 0 2/3 3. mo 0 3/3 4. mo 0 / 5. mo 0 / So, even though "more" evaluates to 0, it is treated as true in the {if more ...} fields, otherwise nothing would be printed ({ IF more "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"}). On the other hand, it is always treated as true - the 4. and 5. should not appear. Does anyone understand this? Monika. |
#3
|
|||
|
|||
Oh oh ... I just tried something else:
{ if true "1" "2" } { if false "1" "2" } both show 1. TRUE, FALSE did not work, either (still showed 1, 1). Neither did 1 for true, 0 for false (unknown opcode). I guess I must be using booleans in Word's mail merge entirely wrong :-( . Are there no boolean literals? Is it not possible to assign booleans to variables (bookmarks)? But { = AND (true, false) } worked, no matter the capitalization and also with 1 and 0, same for OR. So true, false must be the correct literals. This does not make any sense to me. Monika. |
#4
|
|||
|
|||
Just looking at your first message...
The Word field language does not use the keywords or values "true" and "false" to represent true and false. The main change you need to make is to use 1 for true and 0 for false. Although it is not always essential, I would do always use { REF v070 } or { v070 } when you want to use a bookmark value, not just v070 (no mateer what examples you see). It is also worth bearing in mind that Word does not necessarily perform numeric comparisons when you use and operators. If you want to be sure that Word is comparing numbers and not strings, it is better to use an { = } field to subtract one value from the other and compare the result with 0. Peter Jamieson "Monika Krug" wrote in message ... (version: Word 2003) I hope someone can help me with this problem, it is driving me crazy: I have these fields in my document: (The /* comments */ are added for clarity here.) { IF { MERGEFIELD "associations" } = "070" { SET v070 true } { SET v070 false } } { NEXTIF v070 } /* as the first record has associations=070, this results in v070 being set to true and Word going to the next data record */ v070: { v070 } /* shows v070 for debugging - true as expected */ less: { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false} /* this should be true, because 1 is less than 3 */ { SET more { = AND (v070; { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false}) } } /* here is the trouble */ mo { more } /* this should be 1, as true and true results in true - but it is not working */ { IF v070 "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"} /* shows 1/3 as expected */ The relevant columns of the first four rows of data a associations; Total_070; Index_070; 070; ; ; ; 3; 1; ; 3; 2; ; 3; 3; (I.e. for the first record associations=070 and the total and index are empty, for the other records associations is empty, total is always 3 and index is counted from 1 to 3. The part I show above only uses the first two records.) The shown result is: v070: true less: true mo 0 1/3 Why is the result of the AND field 0, even though both parts are true?! I don't get it. What is wrong? Am I using AND incorrectly? I have tested { = AND (true; 1) } and different combinations of true, false, 0, and 1 in the brackets after AND - the result was always as expected, e.g. = AND (true; 1) yields 1. Any ideas? Different, not so important question: I think { = AND (v070; { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } ) } should be working, too, instead of { = AND (v070; { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false}) } . Any ideas why it does not work at all? I get a "!Syntax Error, ". I have another weird problem with the same mail merge document: 1. When I open it and preview for the first time (with the first data record, or actually with the first two as I use nextif), the result is true, true, 0, 1/3 as shown above, so as expected except for the weird 0. 2. When I highlight all and press F9, suddenly true, false, 0, / are displayed. How is that possible?! 3. When I click to preview the next record and back to #1, it now shows true, true, 0, 1/3 again. (At least I have found this workaround finally, so I don't have to close and reopen my document all the time.) I first thought, maybe Word now (after the second step, i.e. after pressing F9) is at the second data record and evaluating that one - but in that case, v070 should be false (which remains true) and the "less" statement should still be true, as 23, and not without any reason become false. Help particularly with the first problem would be greatly appreciated. Regards, Monika. |
#5
|
|||
|
|||
Hi Monika,
For a 'tutorial' with examples of how you can do 'AND' comparisons and much more, for both numbers and text, download the Word document at: http://www.wopr.com/cgi-bin/w3t/show...?Number=365442 (url all one line) Although not specifically written with MAILMERGE fields in mind, the logic, syntax etc are the same. Cheers "Monika Krug" wrote in message ... (version: Word 2003) I hope someone can help me with this problem, it is driving me crazy: I have these fields in my document: (The /* comments */ are added for clarity here.) { IF { MERGEFIELD "associations" } = "070" { SET v070 true } { SET v070 false } } { NEXTIF v070 } /* as the first record has associations=070, this results in v070 being set to true and Word going to the next data record */ v070: { v070 } /* shows v070 for debugging - true as expected */ less: { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false} /* this should be true, because 1 is less than 3 */ { SET more { = AND (v070; { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false}) } } /* here is the trouble */ mo { more } /* this should be 1, as true and true results in true - but it is not working */ { IF v070 "{ MERGEFIELD Index_070 }/{ MERGEFIELD Total_070 }"} /* shows 1/3 as expected */ The relevant columns of the first four rows of data a associations; Total_070; Index_070; 070; ; ; ; 3; 1; ; 3; 2; ; 3; 3; (I.e. for the first record associations=070 and the total and index are empty, for the other records associations is empty, total is always 3 and index is counted from 1 to 3. The part I show above only uses the first two records.) The shown result is: v070: true less: true mo 0 1/3 Why is the result of the AND field 0, even though both parts are true?! I don't get it. What is wrong? Am I using AND incorrectly? I have tested { = AND (true; 1) } and different combinations of true, false, 0, and 1 in the brackets after AND - the result was always as expected, e.g. = AND (true; 1) yields 1. Any ideas? Different, not so important question: I think { = AND (v070; { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } ) } should be working, too, instead of { = AND (v070; { IF { MERGEFIELD "Index_070" } { MERGEFIELD "Total_070" } true false}) } . Any ideas why it does not work at all? I get a "!Syntax Error, ". I have another weird problem with the same mail merge document: 1. When I open it and preview for the first time (with the first data record, or actually with the first two as I use nextif), the result is true, true, 0, 1/3 as shown above, so as expected except for the weird 0. 2. When I highlight all and press F9, suddenly true, false, 0, / are displayed. How is that possible?! 3. When I click to preview the next record and back to #1, it now shows true, true, 0, 1/3 again. (At least I have found this workaround finally, so I don't have to close and reopen my document all the time.) I first thought, maybe Word now (after the second step, i.e. after pressing F9) is at the second data record and evaluating that one - but in that case, v070 should be false (which remains true) and the "less" statement should still be true, as 23, and not without any reason become false. Help particularly with the first problem would be greatly appreciated. Regards, Monika. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.788 / Virus Database: 533 - Release Date: 1/11/2004 |
#6
|
|||
|
|||
Peter Jamieson" wrote:
The Word field language does not use the keywords or values "true" and "false" to represent true and false. The main change you need to make is to use 1 for true and 0 for false. Although it is not always essential, I would do always use { REF v070 } or { v070 } when you want to use a bookmark value, not just v070 Thank you thank you thank you! You solved most of my mail merge problems and saved me from certain insanity with your post :-) . Live long and prosper, Monika. |
#7
|
|||
|
|||
"macropod" writes:
For a 'tutorial' with examples of how you can do 'AND' comparisons and much more, for both numbers and text, download the Word document at: http://www.wopr.com/cgi-bin/w3t/show...?Number=365442 (url all one line) Although not specifically written with MAILMERGE fields in mind, the logic, syntax etc are the same. Thank you! That's a very comprehensive tutorial and will help me a lot with further mail merge problems. A note: In your tutorial you write e.g. AND(x,y). I have tried this and I get a syntax error. It only worked with ; instead of ,. Maybe this was changed in a recent Word version? The Word help also says to use a comma. Greetings, Monika. |
#8
|
|||
|
|||
Hi Monika,
At the end of the description of 'AND(x,y)', you'll see the number '1'. That is a calculated field result using the syntax described. Select the '1' and press Shift-F9 to reveal the field coding, which is exactly as shown in red. In other words, it works. But, as described under 'Testing Or Returning Text Strings With Logical Functions In Bookmarks', you need a different approach if you're not working with numbers alone. Cheers "Monika Krug" wrote in message ... "macropod" writes: For a 'tutorial' with examples of how you can do 'AND' comparisons and much more, for both numbers and text, download the Word document at: http://www.wopr.com/cgi-bin/w3t/show...?Number=365442 (url all one line) Although not specifically written with MAILMERGE fields in mind, the logic, syntax etc are the same. Thank you! That's a very comprehensive tutorial and will help me a lot with further mail merge problems. A note: In your tutorial you write e.g. AND(x,y). I have tried this and I get a syntax error. It only worked with ; instead of ,. Maybe this was changed in a recent Word version? The Word help also says to use a comma. Greetings, Monika. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.788 / Virus Database: 533 - Release Date: 1/11/2004 |
#9
|
|||
|
|||
"macropod" wrote:
At the end of the description of 'AND(x,y)', you'll see the number '1'. That is a calculated field result using the syntax described. Select the '1' and press Shift-F9 to reveal the field coding, which is exactly as shown in red. In other words, it works. It works - until I press F9 for updating the field, then I get a syntax error. I have just tested it with different Word versions: On Word 2003 AND(x;y) works, AND(x,y) does not, on Word 2002 it's the other way around. Monika. |
#10
|
|||
|
|||
A note: In your tutorial you write e.g. AND(x,y). I have
tried this and I get a syntax error. It only worked with ; instead of ,. Maybe this was changed in a recent Word version? This is almost certainly because of differences in regional settings. English USA, UK and probably elsewhere use comma as a list separator whereas e.g. German (Germany) uses semi-colon. It looks as if the "field language" expects that list character to separate parameter lists within fields, whereas (for example") a language such as C would use a comma regardless of region/locale. Peter Jamieson "Monika Krug" wrote in message ... "macropod" writes: For a 'tutorial' with examples of how you can do 'AND' comparisons and much more, for both numbers and text, download the Word document at: http://www.wopr.com/cgi-bin/w3t/show...?Number=365442 (url all one line) Although not specifically written with MAILMERGE fields in mind, the logic, syntax etc are the same. Thank you! That's a very comprehensive tutorial and will help me a lot with further mail merge problems. A note: In your tutorial you write e.g. AND(x,y). I have tried this and I get a syntax error. It only worked with ; instead of ,. Maybe this was changed in a recent Word version? The Word help also says to use a comma. Greetings, Monika. |
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
using SUMIF function with compound conditions | agarwaldvk | Worksheet Functions | 12 | August 10th, 2004 12:23 AM |
compound index | taccea | Running & Setting Up Queries | 4 | July 15th, 2004 05:44 AM |
Averaging compound numbers | Old Red One | General Discussion | 4 | June 14th, 2004 12:06 PM |
calculate compound growth | Peter Atherton | Worksheet Functions | 1 | March 3rd, 2004 04:25 PM |
compound sum interest factor function? | joeleandri | Worksheet Functions | 5 | November 26th, 2003 07:28 PM |