Reply
 
Thread Tools Display Modes
  #1   Report Post  
Rong
 
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   Report Post  
Graham Mayor
 
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   Report Post  
Rong
 
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   Report Post  
Graham Mayor
 
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   Report Post  
Rong
 
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   Report Post  
Graham Mayor
 
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   Report Post  
Ed Bloomfield
 
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   Report Post  
Graham Mayor
 
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



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
Mail Merge Word 2003 Issue S.Nicks Mailmerge 5 February 20th 09 01:55 AM
mail merge with attachments AS Mailmerge 5 April 9th 05 09:49 AM
Problem with automating mail merge HeatherO Mailmerge 2 March 29th 05 10:11 PM
Mail Merge Issue With Office 97 - Excel Data Source Matt Thorley Mailmerge 1 February 15th 05 11:38 PM
Word-Excel 2003 - Mail Merge Recipients problem AYager Mailmerge 2 January 11th 05 04:11 AM


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