Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-11-2014, 05:53 PM
bufferemail bufferemail is offline Page Break on Key Change Windows 7 64bit Page Break on Key Change Office 2010 32bit
Novice
Page Break on Key Change
 
Join Date: May 2014
Posts: 4
bufferemail is on a distinguished road
Default Page Break on Key Change

I can't make sense of the syntax for IF fields and I've gotten to the point where the bulk of my output is correct but nothing happens when a key value changes between lines.

{QUOTE{IF{MERGESEQ}=1 "{SET Key1 ""}{SET Key2 ""}"}"IF{IF{={IF{MERGEFIELD ED}= {REF Key2} 1 0}*{IF{MERGEDFILED NUM}={REF Key1} 1 0}}=0"{IF{MERGESEQ}>1 ""}{MERGEDFIELD NUM}{SET Key1 {MERGEFIELD NUM}}"}{IF{MERGEFILED ED}<>{REF Key2} "{SET Key2 {MERGEFIELD ED}}"}{MERGEFIELD LAST}, {MERGEFIELD FIRST}"}


The data source is sorted first by ED, then by NUM.

I'd like the output to be like this so that when the entries with like EDs end and a new ED starts it would insert a page break, then the new ED value, then another page break.

--page break--
ED1
--page break--
NUM1
Last, First
Last, First

NUM2
Last, First

--pagebreak--
ED2
--pagebreak--
NUM3
Last, First
Last, First




Is my structure correct and if so where would I place the page break so that it appears when the ED changes?

Thank you in advance!
Reply With Quote
  #2  
Old 05-11-2014, 06:55 PM
macropod's Avatar
macropod macropod is offline Page Break on Key Change Windows 7 32bit Page Break on Key Change Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
{QUOTE{IF{MERGESEQ}= 1 "{SET Key1 ""}{SET Key2 ""}"}"{IF{MERGEFIELD ED}<> {REF Key1} "{IF{MERGESEQ}> 1 {QUOTE 12}}{MERGEFIELD ED}{SET Key1 {MERGEFIELD ED}}¶
"}{IF{MERGEFIELD NUM}<> {REF Key2} "{SET Key2 {MERGEFIELD NUM}}¶
{MERGEFIELD NUM}¶
"}{MERGEFIELD LAST} {MERGEFIELD FIRST}¶
"}
Note: You'll need to replace the ¶ symbols with real paragraph breaks or line breaks. You also need all of the spaces indicated - the field 'code' in your post is missing numerous critical spaces.

For a macro to convert the above to a working field code, see: http://www.gmayor.com/export_field.htm#TextToField
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-11-2014, 09:28 PM
bufferemail bufferemail is offline Page Break on Key Change Windows 7 64bit Page Break on Key Change Office 2010 32bit
Novice
Page Break on Key Change
 
Join Date: May 2014
Posts: 4
bufferemail is on a distinguished road
Default

Thanks for the quick reply. I tried your code, every space and case accounted for and the output is:

Quote:
ED1¶



NUM1¶

LAST, FIRST
--page break --
ED1¶



¶LAST, FIRST
--page break--
Any thoughts? This is a real head scratcher for me.
Reply With Quote
  #4  
Old 05-11-2014, 09:38 PM
macropod's Avatar
macropod macropod is offline Page Break on Key Change Windows 7 32bit Page Break on Key Change Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Are you doing a Directory Merge?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-11-2014, 09:42 PM
bufferemail bufferemail is offline Page Break on Key Change Windows 7 64bit Page Break on Key Change Office 2010 32bit
Novice
Page Break on Key Change
 
Join Date: May 2014
Posts: 4
bufferemail is on a distinguished road
Default

Yes. It's the first thing I did and just in case checked to verify that the settings didn't change for some reason.
Reply With Quote
  #6  
Old 05-11-2014, 09:52 PM
macropod's Avatar
macropod macropod is offline Page Break on Key Change Windows 7 32bit Page Break on Key Change Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The only way I can get the result you depicted using the field code I posted is if the merge is not a Directory type. So, either you're not using that or there's an error in your implementation of the field code. See attached field code implementation.
Attached Files
File Type: doc Test Mailmerge Main Document.doc (30.0 KB, 24 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 05-11-2014, 10:17 PM
bufferemail bufferemail is offline Page Break on Key Change Windows 7 64bit Page Break on Key Change Office 2010 32bit
Novice
Page Break on Key Change
 
Join Date: May 2014
Posts: 4
bufferemail is on a distinguished road
Default

Your file worked. Thank you!

I did check your code vs mine which yielded a view spaces that didn't match. After I corrected them and tried again my file still didn't work and outputed the same thing I was getting before. Is it possible that the .doc format vs docx is causing some issues on how the IF fields operate?
Reply With Quote
  #8  
Old 05-11-2014, 10:21 PM
macropod's Avatar
macropod macropod is offline Page Break on Key Change Windows 7 32bit Page Break on Key Change Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by bufferemail View Post
Is it possible that the .doc format vs docx is causing some issues on how the IF fields operate?
No, they work exactly the same and, FWIW, I used the macro referred to in post #2 to convert the field 'code' in that post back to the working field code in the attachment to my last post.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
key, mail merge, page break

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Break on Key Change Delete a page after Section Break Next Page Aston Word 9 04-27-2022 07:38 AM
Page Break on Key Change First section will not 'insert' blank page even though sectn 2 is 'odd' page break Pat_Hodgson Word 6 12-01-2013 04:22 PM
Page Break on Key Change Section break makes style change when printing or saving as pdf bohk Word 4 06-07-2013 02:34 PM
Page Break on Key Change Section Break (Next Page) replaces Section Break (Continuous) when deleted Carlabasson Word 2 03-25-2013 10:13 PM
paragaph hard break, soft break and ...strange break czomberzdaniela Word 2 12-03-2010 06:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft