Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
JB reluctantly from WP JB reluctantly from WP is offline
external usenet poster
 
Posts: 5
Default Mergefield with comma, suppress comma if field blank

Hello,

I have an Excel database file, and am merging into a Word document. I am
familiar with Word's merge process.

I need to display mergefields "LAST_NAME, FIRST_NAME" but only want the
comma if FIRST_NAME field is not blank. When FIRST_NAME field is blank, I
only want to diplay the LAST_NAME field. I'm having a heckuva time trying to
get the right IF statement to produce the wanted results.

My attempt at the IF statement: {IF {MERGEFIELD "FIRST_NAME"} "" "
{MERGEFIELD "LAST_NAME"},"} {MERGEFIELD "FIRST_NAME"}

I have a feeling I'm really close! However, the results produced by this
statement resulted in the last name not printing at all if the first name was
blank.

Any assistance is greatly appreciated!

~Julie
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mergefield with comma, suppress comma if field blank

{IF {MERGEFIELD "FIRST_NAME"} "" "
{MERGEFIELD "LAST_NAME"},"} {MERGEFIELD "FIRST_NAME"}

{ MERGEFIELD LAST_NAME }{ IF "{ MERGEFIELD FIRST_NAME }" = ""
"" ", { MERGEFIELD FIRST_NAME }" }

If you're only using Word 2002 or 2003 you can probably use

{ MERGEFIELD LAST_NAME }{ MERGEFIELD FIRST_NAME \b ", " }

Peter Jamieson

"JB reluctantly from WP"
wrote in message ...
Hello,

I have an Excel database file, and am merging into a Word document. I am
familiar with Word's merge process.

I need to display mergefields "LAST_NAME, FIRST_NAME" but only want the
comma if FIRST_NAME field is not blank. When FIRST_NAME field is blank, I
only want to diplay the LAST_NAME field. I'm having a heckuva time trying
to
get the right IF statement to produce the wanted results.

My attempt at the IF statement: {IF {MERGEFIELD "FIRST_NAME"} "" "
{MERGEFIELD "LAST_NAME"},"} {MERGEFIELD "FIRST_NAME"}

I have a feeling I'm really close! However, the results produced by this
statement resulted in the last name not printing at all if the first name
was
blank.

Any assistance is greatly appreciated!

~Julie



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Mergefield with comma, suppress comma if field blank

Hi Julie,

Try:
{IF{MERGEFIELD FIRST_NAME}= "" "{MERGEFIELD FIRST_NAME}, "}{MERGEFIELD
LAST_NAME}
to put 'FIRST_NAME' before 'LAST_NAME', or
{MERGEFIELD LAST_NAME}{IF{MERGEFIELD FIRST_NAME}= "" "" ", {MERGEFIELD
FIRST_NAME}"}
to put 'LAST_NAME' before 'FIRST_NAME',
Note how 'LAST_NAME' is outside the IF test in both cases.

Cheers
--
macropod
[MVP - Microsoft Word]


"JB reluctantly from WP"
wrote in message ...
Hello,

I have an Excel database file, and am merging into a Word document. I am
familiar with Word's merge process.

I need to display mergefields "LAST_NAME, FIRST_NAME" but only want the
comma if FIRST_NAME field is not blank. When FIRST_NAME field is blank, I
only want to diplay the LAST_NAME field. I'm having a heckuva time trying

to
get the right IF statement to produce the wanted results.

My attempt at the IF statement: {IF {MERGEFIELD "FIRST_NAME"} "" "
{MERGEFIELD "LAST_NAME"},"} {MERGEFIELD "FIRST_NAME"}

I have a feeling I'm really close! However, the results produced by this
statement resulted in the last name not printing at all if the first name

was
blank.

Any assistance is greatly appreciated!

~Julie



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
JB reluctantly from WP JB reluctantly from WP is offline
external usenet poster
 
Posts: 5
Default Mergefield with comma, suppress comma if field blank

Thanks Peter, since I'm "only" using Word 2002 your last suggestion
(...\b...) did the trick!

Thanks to both Peter and Macropod for your quick responses!

~Julie

"Peter Jamieson" wrote:

{IF {MERGEFIELD "FIRST_NAME"} "" "
{MERGEFIELD "LAST_NAME"},"} {MERGEFIELD "FIRST_NAME"}

{ MERGEFIELD LAST_NAME }{ IF "{ MERGEFIELD FIRST_NAME }" = ""
"" ", { MERGEFIELD FIRST_NAME }" }

If you're only using Word 2002 or 2003 you can probably use

{ MERGEFIELD LAST_NAME }{ MERGEFIELD FIRST_NAME \b ", " }

Peter Jamieson

"JB reluctantly from WP"
wrote in message ...
Hello,

I have an Excel database file, and am merging into a Word document. I am
familiar with Word's merge process.

I need to display mergefields "LAST_NAME, FIRST_NAME" but only want the
comma if FIRST_NAME field is not blank. When FIRST_NAME field is blank, I
only want to diplay the LAST_NAME field. I'm having a heckuva time trying
to
get the right IF statement to produce the wanted results.

My attempt at the IF statement: {IF {MERGEFIELD "FIRST_NAME"} "" "
{MERGEFIELD "LAST_NAME"},"} {MERGEFIELD "FIRST_NAME"}

I have a feeling I'm really close! However, the results produced by this
statement resulted in the last name not printing at all if the first name
was
blank.

Any assistance is greatly appreciated!

~Julie




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
IF command to insert a comma if the Title field is not blank K Hyzer Mailmerge 4 September 26th 06 12:00 PM
VBA code to execute for a subsequent mail merge Colonel Blip New Users 4 September 6th 06 11:43 AM
Suppressing Merge Field and text before/after julie Microsoft Word Help 8 November 14th 05 02:50 PM
how do I delete commas in a field when blank haliburton girl Mailmerge 16 October 7th 05 12:22 PM
Unwanted spaces in address on envelopes jen Mailmerge 3 September 26th 05 05:37 AM


All times are GMT +1. The time now is 11:51 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"