Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-11-2014, 05:37 PM
azza azza is offline Using skip record as well as if, then, else Mac OS X Using skip record as well as if, then, else Office 2008 for Mac
Novice
Using skip record as well as if, then, else
 
Join Date: Oct 2014
Posts: 4
azza is on a distinguished road
Default Using skip record as well as if, then, else

I have two requirements for my merge:

1. I want to skip null records
2. I want to include text in non-null records.

e.g. field "Boy4" is a number from a spreadsheet. If the field is null, I want to skip the record (to save space on my tickets) but if it's a number, I need to include text in front of the field like "Boys Aged Four: {MERGEFIELD Boy4}".



I seem to be able to do one or the other but not both - I'm not sure where I'm going wrong and I'd appreciate any help.
Reply With Quote
  #2  
Old 10-11-2014, 07:16 PM
macropod's Avatar
macropod macropod is offline Using skip record as well as if, then, else Windows 7 64bit Using skip record as well as if, then, else Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
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

If 0 isn't a valid result, you could code the SKIPIF field along the lines of:
{SKIPIF {MERGEFIELD Boy4}= 0}
or:
{SKIPIF «Boy4»= 0}

Otherwise, you would probably need to code the SKIPIF field along the lines of:
{SKIPIF {MERGEFIELD Boy4}<> {={MERGEFIELD Boy4}}}
or:
{SKIPIF «Boy4}<> {=«Boy4»}}

Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues. Likewise, you can't type or copy & paste the chevrons (i.e. '« »') - they're part of the actual mergefields, which you can insert from the mailmerge toolbar. The spaces represented in the field construction are all required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-11-2014, 08:16 PM
azza azza is offline Using skip record as well as if, then, else Mac OS X Using skip record as well as if, then, else Office 2008 for Mac
Novice
Using skip record as well as if, then, else
 
Join Date: Oct 2014
Posts: 4
azza is on a distinguished road
Default

Many thanks.

I'm close now (especially thanks to your tip about the spaces being vital).

The fields are now invisible if null but there is still a carriage return when the field is null (or zero).

The code I've got is:

Code:
{SKIPIF { MERGEFIELD Boy4 }=""  }{ IF {MERGEFIELD Boy4 }<>""Boy Aged 4: {MERGEFIELD Boy4 }" "" }
Maybe I need to take the carriage returns out of the document and into the fields somehow.
Reply With Quote
  #4  
Old 10-11-2014, 08:22 PM
azza azza is offline Using skip record as well as if, then, else Mac OS X Using skip record as well as if, then, else Office 2008 for Mac
Novice
Using skip record as well as if, then, else
 
Join Date: Oct 2014
Posts: 4
azza is on a distinguished road
Default

A ha!

It seems I just need to put a carriage return in the code:
Code:
{SKIPIF { MERGEFIELD Boy4 }=""  }{ IF {MERGEFIELD Boy4 }<>""Boy Aged 4: {MERGEFIELD Boy4 }" 
"" }
Thank you again for your help!
Reply With Quote
  #5  
Old 10-11-2014, 08:36 PM
macropod's Avatar
macropod macropod is offline Using skip record as well as if, then, else Windows 7 64bit Using skip record as well as if, then, else Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
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

Since you already have the SKIPIF test, I can't see the point of the further IF test. After all, the record will never appear if { MERGEFIELD Boy4 } is empty.

I also can't follow your IF field's syntax; it's spacing and quote characters are all over the place - you either have too many or too few quotes and too few spaces. It should be something like:
{ IF {MERGEFIELD Boy4 }<> "" "Boy Aged 4: {MERGEFIELD Boy4 }" "" }
or, at an absolute minimum:
{IF{MERGEFIELD Boy4}<> "" "Boy Aged 4: {MERGEFIELD Boy4}"}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 10-11-2014, 11:25 PM
azza azza is offline Using skip record as well as if, then, else Mac OS X Using skip record as well as if, then, else Office 2008 for Mac
Novice
Using skip record as well as if, then, else
 
Join Date: Oct 2014
Posts: 4
azza is on a distinguished road
Default

Oh, okay. I may've over-engineered the "solution".

I was just trying to ensure that if a field has no value (null) then it doesn't take up a line in the merge - it's not enough for it just not to appear.

But yes, you're right - I had another go with just the "if, then" test and it works as I require.

Thank you again for your patience.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using skip record as well as if, then, else Transpose cells and skip? ItsjustB Excel 1 01-09-2013 08:53 AM
Using skip record as well as if, then, else skip to next sentence? moreenz Word 3 08-16-2012 02:41 PM
Footer to Start on Page 1 - skip TOC SQLUSA Word 4 08-12-2012 11:36 AM
avoid duplicete record and merge the record with the existed record hemant.behere Excel 0 01-10-2012 02:53 AM
Using skip record as well as if, then, else skip duplicate letters karen h Mail Merge 10 03-23-2011 08:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:44 AM.


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