Extra Page Only If Necessary (2003 / 2007)

Good evening.

Is there a way to format a page within a multi-page document such that the page will print only if there is actual text to populate it?

I have an existing two-page document, both pages of which contain "hard" text. I added a third page, on which I inserted field codes - not formulas, but individual field codes with IF / THEN instructions added in. These codes will cause customized "Warning" message text to print if the the corresponding field is not populated with the appropriate character, but will print nothing if the field is filled n appropriately. There is no actual text on this page - just the bookmarked field code information..

Configured thus, the document prints as three pages if the required data entry was not performed. The third page contains the "Warning" text.

If the required data entry is performed, a blank third page is generated. This occurs regardless of whether I make the "Warning" page the first page or the third page. Ideally, I would like to have this page be the first page, so that when applicable, the "Warning" page will be on top.

Is it possible to have this third page print only if it is necessary - when the required data entry is not performed, and there is actual data being pulled and printed from the designated field codes?

Re: Extra Page Only If Necessary (2003 / 2007)

You can include a manual page break (Ctrl+Enter) within field codes, so you could place a page break in the IF part or in the ELSE part of an IF field:
<code>
{ IF condition "Warning Text---Page Break---" "" }
</code>
where <code>---Page Break---</code> stands for a manual page break

Re: Extra Page Only If Necessary (2003 / 2007)

I added the page break, but the blank page still prints (when a "1" is entered ion the program field). Would you mind taking a look at the field code to see if I placed the page break appropriately? I have attached a document with the code inserted. Thank you.

Re: Extra Page Only If Necessary (2003 / 2007)

I have combined the two IF statements & I believe the attached will do what you want. As you are only testing for one thing, PNT_9950 equaling "1", there really isn't a need to have the second IF statement.

Re: Extra Page Only If Necessary (2003 / 2007)

Well, the second IF statement instructs the code to print nothing if the program field contains "1", so it is important to the mission at hand. Without it, the document is populated with "1", which is not desired.

I am attempting to get the following result: When "1" is entered in field PNT_9950 and nothing prints on the document (which I have accomplished), the page on which the PNT_9950 code has been inserted will not print. The only instance in which that page would print would be when field PNT_9950 did not contain "1".

Re: Extra Page Only If Necessary (2003 / 2007)

Kevin,

The IF statement has both a true & false section. If the PNT_9950 field does NOT equal "1" it prints the warning text. If PNT_9950 field has any other value (i.e. the IF statement is FALSE), a page break and the PNT_9950 field is inserted.

Maybe that's not you are aiming for. I might have the IF around the wrong way. If that is the case you could simply change the IF statement sign from <> to = . IF «PNT_9950» <font color=red>=</font color=red> "1"

Re: Extra Page Only If Necessary (2003 / 2007)

Matthew and Hans -

Here is what I have determined (in case you are interested):

Hans, your first suggestion does actually work. I was still getting the unwanted blank page (when PNT_9950 equaled "1") because I had page numbers inserted on the document. Once they were removed, the document "behaved" as instructed in both scenarios - When PNT 9950 = "1", no page was generated. When PNT 9950 did not = "1", the error message printed on a third page.

The modified document version you offered also works as desired, though I do not understand how, since you removed the instruction to print nothing if PNT 99950 does equal 1.

Matthew, your version did generate the warning message when appropriate, but also populated the document with a "1" when PNT 99950 = "1" Which is what I expected, since you removed the second IF statement. However, yours looks just like Hans'. So I am not sure how and why these things are working, or not.

Regardless, you have proved a solution. Thank you very much.

May I prevail upon either or both of you for one more step? I need to accommodate two or three different field entry errors or omissions. So I would need to have two or three field codes (modified as you have suggested), on the same page. The problem is. the page breaks push each successive error message onto a new page, as would be expected. So potentially, three extra pages would be generated.

Could I format some other way, so as to allow two or three error messages to print on a single page?

Keep in mind that you should NEVER type the field braces { } yourself, always use Ctrl+F9 (or Insert | Field...) to create them.
<paragraph break> and <page break> are meant to be replaced by real paragraph breaks (Enter) and page breaks (Ctrl+Enter).

Re: Extra Page Only If Necessary (2003 / 2007)

Hans -

I don't use the term "genius" very often, except, of course, when referring to myself. (It's my humility that makes me better than other people.) However, I must say, once again, you found a way to make my almost-functional conception perfectly functional. The supplementary COMPARE code you provided produces the exact result needed. I could have plugged away at it for a week, but I would not have come up with that.

The suggestions I have received from the Lounge have been enormously helpful, enabling me to accomplish things I would otherwise not been been able to do. I get some weird ideas, but do not possess the technical knowledge to bring them all to fruition. Please know that I appreciate all of the assistance I have received from such clever and knowledgeable people Thank you.

Re: Extra Page Only If Necessary (2003 / 2007)

I have had success with this formula with various field code rule variations. But am encountering a problem I cannot account for. I had been installing it on documents with two WARNING rules each, and it worked perfectly. I had assumed that since two rules worked, any number of rules would, as well. However, the IF / COMPARE code seems to allow no more than two field code rule sets. Installation of any more seems to disconnect the preceding code rules (with the WARNING text) such that the WARNINGs will print with no page break separating them from the hard text on the document.

I can find no logical reason for this behavior. The IF / COMPARE code seems as though it would allow for any number of rule sets. I have tried many variations, with no real solution or explanation. I did find a way to allow for more than two rule sets, but it causes either of a set of two WARNINGs grouped together to print on a separate page from any others. I can live with that, if there is no other way to arrange it. But I would prefer to have all WARNINGs on the same page.

I have attached a document which I hope illustrates the situation clearly. I have included three examples and notes derived from my hours of trial and error, to help reduce your trouble shooting time. Example # 2 (name highlighted in green) is the one with which I am encountering the problem.

Is there a reason that the addition of a third field code rule (or more) would sever the IF / COMPARE code from the rest?

Could the variable near the end of the code be involved (the "= 1" part, ijust before the final <page break> in the example below)? I am not sure of its function. It may be moot, if the IF / COMPARE code is really severed by the additional rules.

Re: Extra Page Only If Necessary (2003 / 2007)

In addition to toggling the display of field codes, it probably would help to work in Normal View (Word 2003) or Draft View (Word 2007) so you can see where/how the page break is inserted in the IF field.

Re: Extra Page Only If Necessary (2003 / 2007)

Agreed. I can see the page break location when Examples 1 and 3 on the attachment are Previewed. For some reason, when Example 2 is Previewed, the break is not placed on the document, and the WARNING text is not separated from the hard text. The only difference between Example 1 and Example 2 is that Example 2 has 4 field code rule sets (pardon the awkward terminology) instead of two. I don't see why that would matter.