Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If Mergefield = "* & *"

    We use merges from our donor database to produce donor pledge cards. On the pledge cards I want to indicate if the record is a joint account or not. The only indication I have the record is a joint account is the presence of an "&" in a specific field. Is there a way I can do this? I have tried many different variations of: { IF { MERGEFIELD AccountName } = “ * & * ” “Joint Account” “Not Joint” } and have got no where. Any help would be so appreciated!

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Jeb,

    You probably want something along the line of:
    { IF { instr(MERGEFIELD AccountName, "&") } > 0, “Joint Account” “Not Joint” }

    I'm not sure of the exact syntax but using * which is a wildcard is probably what is causing your current problems. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    New Lounger
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for getting back to me. I am not familiar with the INSTR command. When I entered the example you gave me, with properly created braces, it didn't work.

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Word fields have no INSTR function, so it's not surprising it doesn't work...

    As for detecting the &, you can only do that by testing whether it occurs at a known location in the string, by using as many ? characters as you need before or after it, in conjunction with * on the other side of the wildcard test. You cannot use * on both sides of the test. So, if you know the & could occur anywhere between the 10th & 15th characters, inclusive, you could use six tests, each coded along the lines of:
    {IF{MERGEFIELD AccountName} = "?????????&*" "Joint"}
    {IF{MERGEFIELD AccountName} = "??????????&*" "Joint"}
    {IF{MERGEFIELD AccountName} = "???????????&*" "Joint"}
    etc.
    A brute-force method is your only option.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Paul,

    Can you use a UDF in a Word Merge Field? If so you could do the test there and then just test for True or False or just return the desired text.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    No. UDFs are VBA. Mergefields are fields. Mergefields cannot run VBA. The only fields that can call a VBA process are MacroButton fields, and they require someone to double-click them - something that's not going to happen during a mailmerge.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    New Lounger
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by macropod View Post
    Word fields have no INSTR function, so it's not surprising it doesn't work...

    As for detecting the &, you can only do that by testing whether it occurs at a known location in the string, by using as many ? characters as you need before or after it, in conjunction with * on the other side of the wildcard test. You cannot use * on both sides of the test. So, if you know the & could occur anywhere between the 10th & 15th characters, inclusive, you could use six tests, each coded along the lines of:
    {IF{MERGEFIELD AccountName} = "?????????&*" "Joint"}
    {IF{MERGEFIELD AccountName} = "??????????&*" "Joint"}
    {IF{MERGEFIELD AccountName} = "???????????&*" "Joint"}
    etc.
    A brute-force method is your only option.
    Your idea worked well. Thank you. I know approximately where to find the & within a few characters.

Posting Permissions

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