A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

IF THEN ELSE CODE



 
 
Thread Tools Display Modes
  #1  
Old April 28th, 2010, 03:01 PM posted to microsoft.public.word.mailmerge.fields
manatee08
external usenet poster
 
Posts: 5
Default IF THEN ELSE CODE

Can someone please tell me what is wrong with this code. What I am trying to
do is:

IF NationalFilingDate field is blank, THEN input the ApplicationDate ELSE
input the NationalFilingDate using the format of MMMM dd, yyyy. This is the
code that I have so far:

{ IF { MERGEFIELD NationalFilingDate }= “” { MERGEFIELD ApplicationDate \@
“MMMM dd, yyyy” } { MERGFIELD NationalFilingDate \@ “MMMM dd, yyyy”} }
  #2  
Old April 28th, 2010, 03:29 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default IF THEN ELSE CODE

Are you sure that a blank record entry actually does produce a blank? Insert
the field on its own and see what it produces, then trap that. Otherwise
apart from the smart quotes it looks OK.

Personally I would quote the alternative options also

{ IF { MERGEFIELD NationalFilingDate }= "" "{ MERGEFIELD ApplicationDate \@
"MMMM dd, yyyy" }" "{ MERGFIELD NationalFilingDate \@ "MMMM dd, yyyy"}" }

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"manatee08" wrote in message
...
Can someone please tell me what is wrong with this code. What I am trying
to
do is:

IF NationalFilingDate field is blank, THEN input the ApplicationDate ELSE
input the NationalFilingDate using the format of MMMM dd, yyyy. This is
the
code that I have so far:

{ IF { MERGEFIELD NationalFilingDate }= "" { MERGEFIELD ApplicationDate \@
"MMMM dd, yyyy" } { MERGFIELD NationalFilingDate \@ "MMMM dd, yyyy"} }



  #3  
Old April 28th, 2010, 03:40 PM posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default IF THEN ELSE CODE

What result are you getting?

Did you use Ctrl+F9 to insert each pair of field delimiters { }?

Have you toggle off the display of the field codes and executed the merge?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"manatee08" wrote in message
...
Can someone please tell me what is wrong with this code. What I am trying
to
do is:

IF NationalFilingDate field is blank, THEN input the ApplicationDate ELSE
input the NationalFilingDate using the format of MMMM dd, yyyy. This is
the
code that I have so far:

{ IF { MERGEFIELD NationalFilingDate }= “” { MERGEFIELD ApplicationDate \@
“MMMM dd, yyyy” } { MERGFIELD NationalFilingDate \@ “MMMM dd, yyyy”} }


  #4  
Old April 28th, 2010, 04:43 PM posted to microsoft.public.word.mailmerge.fields
manatee08
external usenet poster
 
Posts: 5
Default IF THEN ELSE CODE

When the field NationalFilingDate is blank, it produces this result: 12:00:00
AM.
Because of this, I am assuming that ApplicationDate won't be produced
because the field is not actually blank, right?

Using the code above, when the NationalFilingDate has no date in the field,
the ApplicationDate has today's date rather than the ApplicationDate, which
by itself produces 10/15/2008.



"Graham Mayor" wrote:

Are you sure that a blank record entry actually does produce a blank? Insert
the field on its own and see what it produces, then trap that. Otherwise
apart from the smart quotes it looks OK.

Personally I would quote the alternative options also

{ IF { MERGEFIELD NationalFilingDate }= "" "{ MERGEFIELD ApplicationDate \@
"MMMM dd, yyyy" }" "{ MERGFIELD NationalFilingDate \@ "MMMM dd, yyyy"}" }

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"manatee08" wrote in message
...
Can someone please tell me what is wrong with this code. What I am trying
to
do is:

IF NationalFilingDate field is blank, THEN input the ApplicationDate ELSE
input the NationalFilingDate using the format of MMMM dd, yyyy. This is
the
code that I have so far:

{ IF { MERGEFIELD NationalFilingDate }= "" { MERGEFIELD ApplicationDate \@
"MMMM dd, yyyy" } { MERGFIELD NationalFilingDate \@ "MMMM dd, yyyy"} }



.

  #5  
Old April 28th, 2010, 05:08 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default IF THEN ELSE CODE

When the field NationalFilingDate is blank, it produces this result:
12:00:00
AM.
Because of this, I am assuming that ApplicationDate won't be produced
because the field is not actually blank, right?


Correct. But you should be OK with

{ IF { MERGEFIELD NationalFilingDate }= "12:00:00 AM" "{ MERGEFIELD
ApplicationDate \@"MMMM dd, yyyy" }" "{ MERGFIELD NationalFilingDate
\@"MMMM dd, yyyy"}" }

Or if it's "12:00:00 AM."

use

{ IF { MERGEFIELD NationalFilingDate }= "12:00:00 AM." "{ MERGEFIELD
ApplicationDate \@"MMMM dd, yyyy" }" "{ MERGFIELD NationalFilingDate
\@"MMMM dd, yyyy"}" }

Longer term, be aware that if for example you change the way you connect
to your data source, the result of { MERGEFIELD NationalFilingDate } may
no longer be the same, and you would need to change the comparand.

Peter Jamieson

http://tips.pjmsn.me.uk

On 28/04/2010 16:43, manatee08 wrote:
When the field NationalFilingDate is blank, it produces this result: 12:00:00
AM.
Because of this, I am assuming that ApplicationDate won't be produced
because the field is not actually blank, right?

Using the code above, when the NationalFilingDate has no date in the field,
the ApplicationDate has today's date rather than the ApplicationDate, which
by itself produces 10/15/2008.



"Graham Mayor" wrote:

Are you sure that a blank record entry actually does produce a blank? Insert
the field on its own and see what it produces, then trap that. Otherwise
apart from the smart quotes it looks OK.

Personally I would quote the alternative options also

{ IF { MERGEFIELD NationalFilingDate }= "" "{ MERGEFIELD ApplicationDate \@
"MMMM dd, yyyy" }" "{ MERGFIELD NationalFilingDate \@ "MMMM dd, yyyy"}" }

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



m wrote in message
...
Can someone please tell me what is wrong with this code. What I am trying
to
do is:

IF NationalFilingDate field is blank, THEN input the ApplicationDate ELSE
input the NationalFilingDate using the format of MMMM dd, yyyy. This is
the
code that I have so far:

{ IF { MERGEFIELD NationalFilingDate }= "" { MERGEFIELD ApplicationDate \@
"MMMM dd, yyyy" } { MERGFIELD NationalFilingDate \@ "MMMM dd, yyyy"} }



.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.