mail merge if ... then else condition

R

Rong

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
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

Rong

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
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

Rong

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?
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

Ed Bloomfield

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
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top