Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Jan 2001
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If Statement and Text (2000 SR-1)

    I am having trouble getting the correct results from an if statement I am writing in a mail merge - Here's the scenerio: Very simple if statement - IF {Fund}="2003 Text" "Result1" "Result2"
    The problem seems to be that Word reads only the numeric part of the {Fund} field and gives me the same results for "2003 Text" and "2003 Name". Does anyone have any experience with this problem? I'm reading the data from an Excel file and I tried reformatting the cells to text. No luck - any help would be appreciated - Gail

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If Statement and Text (2000 SR-1)

    <P ID="edit" class=small>(Edited by Phil Rabichow on 11-Mar-03 13:42. later)</P>Hmmm, for what it's worth, I get the same thing in Word 97 & Excel 97. Haven't had a chance to figure out why yet.

    I'm not sure but this article suggests problems with using Excel that were corrected with SR-3. I can only check this later, but you might try installing the update.

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: If Statement and Text (2000 SR-1)

    I don't know the elegant solution to this problem but here is one that works.

    If you add an alphabetic character to the beginning of both the field and the comparison then it will be treated correctly eg
    {If {quote a {Fund}} = "a2003 Text" "Result 1" "Result 2"}

    I had thought adding a ' in front of the cell in Excel would have done the trick as it forces Excel to treat the number as a string but alas it didn't work.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    Lounger
    Join Date
    Jan 2001
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If Statement and Text (2000 SR-1)

    Thanks - I had worked that one out as I figured it was some sort of weird numeric compare and that it didn't get past the space. Now I just need to find the "elegant" way since this letter has to be generated daily and I don't really want to play with the data all the time! Thanks for your help - Gail

  5. #5
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: If Statement and Text (2000 SR-1)

    Hi Gail,

    I think the problem can be overcome by turning the "Fund" string into a bookmark. For example, your formula:
    {IF{Fund}="2003 Text" "Result1" "Result2"}
    combined with
    {SET Fund {2003 Text}}
    would return Result1, whereas
    {SET Fund {2003 Name}}
    would return Result2

    I haven't used mail merges, so I can't comment on how to turn a mail merge result into a bookmark.

    HTH
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. #6
    Lounger
    Join Date
    Dec 2002
    Location
    Hull, Yorkshire, England
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If Statement and Text (2000 SR-1)

    Hi Gail
    If the data type of the "Fund" field is always text then I believe that if you enclose your merge field (including the field characters "{}") in quotation marks, this should work.
    I.e. instead of { IF {Fund} = etc. use {IF "{Fund}" = etc.
    or instead of { IF {MERGEFIELD Fund } = etc. use { IF "{ MERGEFIELD Fund }" = etc.
    I believe the quotation marks act as a sort of instruction to Word that the value of the field is text and not some other sort of thing.

    Regards.
    Ed

  7. #7
    Lounger
    Join Date
    Jan 2001
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If Statement and Text (2000 SR-1)

    I knew there had to be a good answer to this - Thank you for help - It works beautifully! You are a genius! - Gail

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •