Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jul 2013
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    OR calculation getting an error message in mail merge

    I have an OR calculation in a mail merge and keep getting the "A field calculation error has occured in record (every page in the final doc)". This is frustrating because it works fine once I click OK to all of the errors.

    This is my desired calculation:

    {IF { = OR({MyField}=1,"")}"Happy text", "Sad text"}

    I have some records where {MyField} = 1, and others where {MyField} is NULL. In either case I want those letters to have the same text.

    Any ideas what's causing the errors? Thanks!

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Try:
    {IF{={MERGEFIELD MyField} \# 0} = {MERGEFIELD MyField} "Happy text" "Sad text"}
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Lounger
    Join Date
    Jul 2013
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I'll give another example. The best option really seems to be using the OR function, but every time I try I get a calculation error. This is what I would like:

    {IF { = OR({MyField}=36, 210, 30, 1140)}"Happy text", "Sad text"}

    I simplified it, for instead of "Happy text" I actually have several large paragraphs. The workaround was to just make 4 separate IF statements for each of the criteria. It feels clunky, especially when that is what the OR function was designed for. I guess the question is, can OR ever work in a Word mail merge?
    Last edited by Beeblebrox; 2013-11-08 at 14:17.

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Yes, the OR function will work, but can only test two logical numeric expressions at a time, and can’t directly test text strings at all. The correct syntax would be:
    {IF{=OR({MyField}=0,{MyField}=1)}> 0 "Happy text" "Sad text"}

    You could, of course, nest them, but there is an alternative that handles text comparisons as well:
    {IF{={IF{MyField}= 36 1 0}+{IF{MyField}= 210 1 0} +{IF{MyField}= 30 1 0}+{IF{MyField}= 1140 1 0}}> 0 "Happy text" "Sad text"}
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. The Following User Says Thank You to macropod For This Useful Post:

    Beeblebrox (2013-11-08)

Posting Permissions

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