• How to Test Null (empty) Bookmark

    Author
    Topic
    #458385

    If a book is set to null, say, {SET FileDate }
    How can I test if {FileDate} is a null string?
    {IF {FileDate}=?? “Yes” “No”}
    Thanks.
    Armstrong

    Viewing 0 reply threads
    Author
    Replies
    • #1152539

      If a book is set to null, say, {SET FileDate }
      How can I test if {FileDate} is a null string?
      {IF {FileDate}=?? “Yes” “No”}
      Thanks.
      Armstrong

      Try
      [indent]{ IF{REF “FileDate” }=”” “Yes” “No” }
      [/indent]
      Note: You may want to use nested IF fields to check if the bookmark gives you “Error! Reference source not found.

      • #1152566

        Stuart,
        Thanks a lot.
        Armstrong

        • #1152662

          Stuart,
          Thanks a lot.
          Armstrong

          Hi Armstrong,

          Depending on what you’re after, here’s other two possible ways:
          {={FILEDATE @ DDMMYYYY} # “Yes;;No”}
          or
          {={FILEDATE @ DDMMYYYY} # “00′-’00’-‘0000;;No”}

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #1152666

            Hi Macropod,
            I’m honored to receive your reply. I read a lot of your high value articles on Word fields. I learn a great deal from you. You’re only the one, not Microsoft, in the world telling me explicitly that AND(), OR(), NOT(), can IF() can’t compare text strings. That’s awesome.
            For the current question, in a legal brief, I would like show Filing Date instead if the Application Date is missing (ie, undefined).
            {SET AppDate}{SET FileDate 3/19/2009}
            In this case, what’s the best approach?
            Thanks for your help.

            Armstrong

            • #1152676

              Hi Macropod,
              I’m honored to receive your reply. I read a lot of your high value articles on Word fields. I learn a great deal from you. You’re only the one, not Microsoft, in the world telling me explicitly that AND(), OR(), NOT(), can IF() can’t compare text strings. That’s awesome.
              For the current question, in a legal brief, I would like show Filing Date instead if the Application Date is missing (ie, undefined).
              {SET AppDate}{SET FileDate 3/19/2009}
              In this case, what’s the best approach?
              Thanks for your help.

              Armstrong

              Hi Armstrong,

              Thanks for the compliment.

              If your field codes really are as you’ve posted (ie {SET AppDate}{SET FileDate 3/19/2009}), and don’t have double quotes enclosing the bookmark values, you could use a formula field with an IF test coded as:
              {IF{REF AppDate}= “Err*” {REF FileDate} {REF AppDate}}

              If you do have double quotes enclosing the bookmark values (ie {SET AppDate “”}{SET FileDate “3/19/2009”}), you could use a formula field with an IF test coded as:
              {IF{REF AppDate}= “” {REF FileDate} {REF AppDate}}

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #1152681

              Hi Armstrong,

              Thanks for the compliment.

              If your field codes really are as you’ve posted (ie {SET AppDate}{SET FileDate 3/19/2009}), and don’t have double quotes enclosing the bookmark values, you could use a formula field with an IF test coded as:
              {IF{REF AppDate}= “Err*” {REF FileDate} {REF AppDate}}

              If you do have double quotes enclosing the bookmark values (ie {SET AppDate “”}{SET FileDate “3/19/2009”}), you could use a formula field with an IF test coded as:
              {IF{REF AppDate}= “” {REF FileDate} {REF AppDate}}

              Hi Paul,
              Thanks for telling me about the “Err*” thing. I have never read a single book (Inside Out/Beyond the Manual/Bible,…etc.) on Word 2003/2007 revealing such secret. That’s amazing.
              Actually, there’s one more possibility. The Bookmark is completely undefined. That’s, it isn’t even defined in any {SET} field code. Then, how should I cope with this “worst” scenario?

              Actually, {SET AppDate} causes no trouble in Word 2007. Before your enlightenment, I wrote the following clumsy code:
              {SET NUL}{SET AddDate}{If {AddDate} = {NUL} “Print This” “Print That”}, which isn’t as elegant as yours, of course.

              Armstrong

            • #1152685

              Hi Paul,
              Thanks for telling me about the “Err*” thing. I have never read a single book (Inside Out/Beyond the Manual/Bible,…etc.) on Word 2003/2007 revealing such secret. That’s amazing.
              Actually, there’s one more possibility. The Bookmark is completely undefined. That’s, it isn’t even defined in any {SET} field code. Then, how should I cope with this “worst” scenario?

              Actually, {SET AppDate} causes no trouble in Word 2007. Before your enlightenment, I wrote the following clumsy code:
              {SET NUL}{SET AddDate}{If {AddDate} = {NUL} “Print This” “Print That”}, which isn’t as elegant as yours, of course.

              Armstrong

              Hi Armstrong,

              The first version of the field code (ie {IF{REF AppDate}= “Err*” {REF FileDate} {REF AppDate}}) will handle a missing AppDate bookmark just as well – since that’s what {SET AppDate} amounts to.

              The ‘ “Err*” thing’ you refer to is simply string testing with a wildcard – it saves testing the full output. I think you’ll find examples of this in some of the field codes in my Date Calc tutorial.

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #1152691

              The ‘ “Err*” thing’ you refer to is simply string testing with a wildcard – it saves testing the full output. I think you’ll find examples of this in some of the field codes in my Date Calc tutorial.

              Hi Paul,
              The more you talk, the more I’m humbled. Wait a minute, do you mean {IF} can do wildcard comparisons? Do you mean “wildcard” in the same sense as found in “Find and Replace”? Definitely I’ve to re-study your Date Calc tutorial. Thanks.
              Armstrong

            • #1152692

              Hi Paul,
              The more you talk, the more I’m humbled. Wait a minute, do you mean {IF} can do wildcard comparisons? Do you mean “wildcard” in the same sense as found in “Find and Replace”? Definitely I’ve to re-study your Date Calc tutorial. Thanks.
              Armstrong

              Hi Armstrong,

              Nothing so sophisticated as you get with Word’s “Find and Replace”, unfortunately – just the good old ‘*’ and ‘?’ wilcards, for ‘any string’ and ‘any character’, respectively.

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

    Viewing 0 reply threads
    Reply To: How to Test Null (empty) Bookmark

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: