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  

mail merge if ... then else condition



 
 
Thread Tools Display Modes
  #1  
Old April 22nd, 2005, 10:58 PM
Rong
external usenet poster
 
Posts: n/a
Default mail merge if ... then else condition

I am using the 'if.. then ...else' to put values into the word letter. Works
fine when the value is there, but it also puts the value in when the
condition is not true??
Also I would like to next this capability I have 10 codes to replace with
Names.
any help on either situation thanks Rong
  #2  
Old April 23rd, 2005, 07:14 AM
Graham Mayor
external usenet poster
 
Posts: n/a
Default

Perhaps if you were to explain *exactly* what it is you are doing we could
advise where you are going wrong.

--

Graham Mayor - Word MVP

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




Rong wrote:
I am using the 'if.. then ...else' to put values into the word
letter. Works fine when the value is there, but it also puts the
value in when the condition is not true??
Also I would like to next this capability I have 10 codes to replace
with Names.
any help on either situation thanks Rong



  #3  
Old April 23rd, 2005, 05:04 PM
Rong
external usenet poster
 
Posts: n/a
Default

From Rong
statement is in Word 2003, letter document
There is a select in the first line of the letter to bypass records if there
is NOT a 5x5 int he AHD_PGM_ID field, this works fine.
The problem statement is (sampleis without paran's)

if mergefield AHD_pgm_id = "5x5 Team-AG" " Al Gianotti, " ""
it does the replace for other then that condition

data is in a sheet of an excel workbood - 2003
this is a sample of the data which is treated as = to the test and the name
is displayed in the letters
5x5 Team-PB
5x5
5x5
5x5 Team-DU

I am trying to replace those initials with the proper complete name.
there are a series fo 10 'teams'
Is there some other solution?
Rong




"Graham Mayor" wrote:

Perhaps if you were to explain *exactly* what it is you are doing we could
advise where you are going wrong.

--

Graham Mayor - Word MVP

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




Rong wrote:
I am using the 'if.. then ...else' to put values into the word
letter. Works fine when the value is there, but it also puts the
value in when the condition is not true??
Also I would like to next this capability I have 10 codes to replace
with Names.
any help on either situation thanks Rong




  #4  
Old April 23rd, 2005, 06:02 PM
Graham Mayor
external usenet poster
 
Posts: n/a
Default

It appears to be the leading 5 which causes the error. The condition sees
this as a numeric field and ignores the rest. Ensuring that the data does
not start with a 5 seems to do the trick (at least with your quoted data).
Add a couple of spaces in the field construction e.g.

{ IF " { MERGEFIELD AHD_pgm_id }" = " 5x5 Team-AG" "Al Gianotti," "" }

This produces a true result only for a data field that contains - 5x5
Team-AG


--

Graham Mayor - Word MVP

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



Rong wrote:
From Rong
statement is in Word 2003, letter document
There is a select in the first line of the letter to bypass records
if there is NOT a 5x5 int he AHD_PGM_ID field, this works fine.
The problem statement is (sampleis without paran's)

if mergefield AHD_pgm_id = "5x5 Team-AG" " Al Gianotti, " ""
it does the replace for other then that condition

data is in a sheet of an excel workbood - 2003
this is a sample of the data which is treated as = to the test and
the name is displayed in the letters
5x5 Team-PB
5x5
5x5
5x5 Team-DU

I am trying to replace those initials with the proper complete name.
there are a series fo 10 'teams'
Is there some other solution?
Rong




"Graham Mayor" wrote:

Perhaps if you were to explain *exactly* what it is you are doing we
could advise where you are going wrong.

--

Graham Mayor - Word MVP

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




Rong wrote:
I am using the 'if.. then ...else' to put values into the word
letter. Works fine when the value is there, but it also puts the
value in when the condition is not true??
Also I would like to next this capability I have 10 codes to replace
with Names.
any help on either situation thanks Rong



  #5  
Old April 23rd, 2005, 06:58 PM
Rong
external usenet poster
 
Posts: n/a
Default

Thanks for the tip
does not work on my machine.
I did that change to the Word form - no difference
I went to the excel data reformated the cell to 'text'
tried it left justified, no change
tried it right justufied, no change
changed the data to 'Team-AG 5x5' that failed the 5x5 test
(it seems that it only tests from the start of the field, no '*' type support)

Version of Word 2003 is 11.6359.6360 SP1

looks as if I have to seperate that field into 2 - then it seems to work.
any other thoughts?
"Graham Mayor" wrote:

It appears to be the leading 5 which causes the error. The condition sees
this as a numeric field and ignores the rest. Ensuring that the data does
not start with a 5 seems to do the trick (at least with your quoted data).
Add a couple of spaces in the field construction e.g.

{ IF " { MERGEFIELD AHD_pgm_id }" = " 5x5 Team-AG" "Al Gianotti," "" }

This produces a true result only for a data field that contains - 5x5
Team-AG


--

Graham Mayor - Word MVP

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



Rong wrote:
From Rong
statement is in Word 2003, letter document
There is a select in the first line of the letter to bypass records
if there is NOT a 5x5 int he AHD_PGM_ID field, this works fine.
The problem statement is (sampleis without paran's)

if mergefield AHD_pgm_id = "5x5 Team-AG" " Al Gianotti, " ""
it does the replace for other then that condition

data is in a sheet of an excel workbood - 2003
this is a sample of the data which is treated as = to the test and
the name is displayed in the letters
5x5 Team-PB
5x5
5x5
5x5 Team-DU

I am trying to replace those initials with the proper complete name.
there are a series fo 10 'teams'
Is there some other solution?
Rong




"Graham Mayor" wrote:

Perhaps if you were to explain *exactly* what it is you are doing we
could advise where you are going wrong.

--

Graham Mayor - Word MVP

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




Rong wrote:
I am using the 'if.. then ...else' to put values into the word
letter. Works fine when the value is there, but it also puts the
value in when the condition is not true??
Also I would like to next this capability I have 10 codes to replace
with Names.
any help on either situation thanks Rong




  #6  
Old April 23rd, 2005, 07:16 PM
Graham Mayor
external usenet poster
 
Posts: n/a
Default

My original tests (same Word version) used a Word table, but I have retested
with the data in an Excel table and it still works fine here as posted. I
have no other suggestions to offer.

--

Graham Mayor - Word MVP

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




Rong wrote:
Thanks for the tip
does not work on my machine.
I did that change to the Word form - no difference
I went to the excel data reformated the cell to 'text'
tried it left justified, no change
tried it right justufied, no change
changed the data to 'Team-AG 5x5' that failed the 5x5 test
(it seems that it only tests from the start of the field, no '*' type
support)

Version of Word 2003 is 11.6359.6360 SP1

looks as if I have to seperate that field into 2 - then it seems to
work.
any other thoughts?
"Graham Mayor" wrote:

It appears to be the leading 5 which causes the error. The condition
sees this as a numeric field and ignores the rest. Ensuring that the
data does not start with a 5 seems to do the trick (at least with
your quoted data). Add a couple of spaces in the field construction
e.g.

{ IF " { MERGEFIELD AHD_pgm_id }" = " 5x5 Team-AG" "Al Gianotti,"
"" }

This produces a true result only for a data field that contains - 5x5
Team-AG


--

Graham Mayor - Word MVP

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



Rong wrote:
From Rong
statement is in Word 2003, letter document
There is a select in the first line of the letter to bypass records
if there is NOT a 5x5 int he AHD_PGM_ID field, this works fine.
The problem statement is (sampleis without paran's)

if mergefield AHD_pgm_id = "5x5 Team-AG" " Al Gianotti, " ""
it does the replace for other then that condition

data is in a sheet of an excel workbood - 2003
this is a sample of the data which is treated as = to the test and
the name is displayed in the letters
5x5 Team-PB
5x5
5x5
5x5 Team-DU

I am trying to replace those initials with the proper complete name.
there are a series fo 10 'teams'
Is there some other solution?
Rong




"Graham Mayor" wrote:

Perhaps if you were to explain *exactly* what it is you are doing
we could advise where you are going wrong.

--

Graham Mayor - Word MVP

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




Rong wrote:
I am using the 'if.. then ...else' to put values into the word
letter. Works fine when the value is there, but it also puts the
value in when the condition is not true??
Also I would like to next this capability I have 10 codes to
replace with Names.
any help on either situation thanks Rong



  #7  
Old April 28th, 2005, 02:23 PM
Ed Bloomfield
external usenet poster
 
Posts: n/a
Default

It seems the thing that is not working may be that Word only looks at the
first 3 or 4 characters in deciding whether there's a match between the
field content and the test variable content.

For example,

{ IF { MERGEFIELD Name1 } = "5x5 Smith" "george" "Vacant" }



using the following data for Name1



5x5 Hello

5x5 Smith

5x5 Abel



as the data, will result in george as the output for every record.



Therefore, I'd suggest you vary the 1st 3 or 4 characters in your test
variable so there will be a test rather than have the same characters in the
first 3 spaces of the field for every test variable, resulting in the answer
being the same for every variation of the test.



Ed Bloomfield



"Graham Mayor" wrote in message
...

My original tests (same Word version) used a Word table, but I have
retested
with the data in an Excel table and it still works fine here as posted. I
have no other suggestions to offer.

--

Graham Mayor - Word MVP

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




Rong wrote:
Thanks for the tip
does not work on my machine.
I did that change to the Word form - no difference
I went to the excel data reformated the cell to 'text'
tried it left justified, no change
tried it right justufied, no change
changed the data to 'Team-AG 5x5' that failed the 5x5 test
(it seems that it only tests from the start of the field, no '*' type
support)

Version of Word 2003 is 11.6359.6360 SP1

looks as if I have to seperate that field into 2 - then it seems to
work.
any other thoughts?
"Graham Mayor" wrote:

It appears to be the leading 5 which causes the error. The condition
sees this as a numeric field and ignores the rest. Ensuring that the
data does not start with a 5 seems to do the trick (at least with
your quoted data). Add a couple of spaces in the field construction
e.g.

{ IF " { MERGEFIELD AHD_pgm_id }" = " 5x5 Team-AG" "Al Gianotti,"
"" }

This produces a true result only for a data field that contains - 5x5
Team-AG


--

Graham Mayor - Word MVP

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



Rong wrote:
From Rong
statement is in Word 2003, letter document
There is a select in the first line of the letter to bypass records
if there is NOT a 5x5 int he AHD_PGM_ID field, this works fine.
The problem statement is (sampleis without paran's)

if mergefield AHD_pgm_id = "5x5 Team-AG" " Al Gianotti, " ""
it does the replace for other then that condition

data is in a sheet of an excel workbood - 2003
this is a sample of the data which is treated as = to the test and
the name is displayed in the letters
5x5 Team-PB
5x5
5x5
5x5 Team-DU

I am trying to replace those initials with the proper complete name.
there are a series fo 10 'teams'
Is there some other solution?
Rong




"Graham Mayor" wrote:

Perhaps if you were to explain *exactly* what it is you are doing
we could advise where you are going wrong.

--

Graham Mayor - Word MVP

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




Rong wrote:
I am using the 'if.. then ...else' to put values into the word
letter. Works fine when the value is there, but it also puts the
value in when the condition is not true??
Also I would like to next this capability I have 10 codes to
replace with Names.
any help on either situation thanks Rong





  #8  
Old April 28th, 2005, 03:07 PM
Graham Mayor
external usenet poster
 
Posts: n/a
Default

Try it with the following (note the quotes and spaces)

{ IF " { MERGEFIELD Name1 }" = " 5x5 Smith" "George" "Vacant" }

If your premise that it only looks at the first 3 or 4 characters were true
then you would get George for every record.

--

Graham Mayor - Word MVP

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





Ed Bloomfield wrote:
It seems the thing that is not working may be that Word only looks at
the first 3 or 4 characters in deciding whether there's a match
between the field content and the test variable content.

For example,

{ IF { MERGEFIELD Name1 } = "5x5 Smith" "george" "Vacant" }



using the following data for Name1



5x5 Hello

5x5 Smith

5x5 Abel



as the data, will result in george as the output for every record.



Therefore, I'd suggest you vary the 1st 3 or 4 characters in your test
variable so there will be a test rather than have the same characters
in the first 3 spaces of the field for every test variable, resulting
in the answer being the same for every variation of the test.



Ed Bloomfield



"Graham Mayor" wrote in message
...

My original tests (same Word version) used a Word table, but I have
retested
with the data in an Excel table and it still works fine here as
posted. I have no other suggestions to offer.

--

Graham Mayor - Word MVP

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




Rong wrote:
Thanks for the tip
does not work on my machine.
I did that change to the Word form - no difference
I went to the excel data reformated the cell to 'text'
tried it left justified, no change
tried it right justufied, no change
changed the data to 'Team-AG 5x5' that failed the 5x5 test
(it seems that it only tests from the start of the field, no '*'
type support)

Version of Word 2003 is 11.6359.6360 SP1

looks as if I have to seperate that field into 2 - then it seems to
work.
any other thoughts?
"Graham Mayor" wrote:

It appears to be the leading 5 which causes the error. The
condition sees this as a numeric field and ignores the rest.
Ensuring that the data does not start with a 5 seems to do the
trick (at least with your quoted data). Add a couple of spaces in
the field construction e.g.

{ IF " { MERGEFIELD AHD_pgm_id }" = " 5x5 Team-AG" "Al Gianotti,"
"" }

This produces a true result only for a data field that contains -
5x5 Team-AG


--

Graham Mayor - Word MVP

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



Rong wrote:
From Rong
statement is in Word 2003, letter document
There is a select in the first line of the letter to bypass
records if there is NOT a 5x5 int he AHD_PGM_ID field, this works
fine.
The problem statement is (sampleis without paran's)

if mergefield AHD_pgm_id = "5x5 Team-AG" " Al Gianotti, " ""
it does the replace for other then that condition

data is in a sheet of an excel workbood - 2003
this is a sample of the data which is treated as = to the test and
the name is displayed in the letters
5x5 Team-PB
5x5
5x5
5x5 Team-DU

I am trying to replace those initials with the proper complete
name. there are a series fo 10 'teams'
Is there some other solution?
Rong




"Graham Mayor" wrote:

Perhaps if you were to explain *exactly* what it is you are doing
we could advise where you are going wrong.

--

Graham Mayor - Word MVP

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




Rong wrote:
I am using the 'if.. then ...else' to put values into the word
letter. Works fine when the value is there, but it also puts the
value in when the condition is not true??
Also I would like to next this capability I have 10 codes to
replace with Names.
any help on either situation thanks Rong



 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting tab stops in Mail Merge for a Catalog/phone list Terry General Discussion 2 July 10th, 2006 02:19 PM
Running mail merge on another computer John Williams Mailmerge 4 September 6th, 2004 04:15 PM
Customize a Mail Merge doc Neh Mailmerge 1 September 1st, 2004 12:47 AM
Secured DB for a Word Mail Merge problem Tony_VBACoder General Discussion 1 August 30th, 2004 10:11 PM
Secured DB for a Word Mail Merge problem Tony_VBACoder Mailmerge 0 August 30th, 2004 07:32 PM


All times are GMT +1. The time now is 06:40 AM.


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