• Empty bookmark gives REF field error

    Author
    Topic
    #472332

    I have a userform that helps me create a meeting minutes report. It has a bookmark called MeetingFrequency which offers combobox values such as Monthly, Weekly, etc. This field comes before the MeetingTitle bookmark. Since not all meeting titles require a meeting frequency to precede it, one of the values I offer my users for MeetingFrequency is “blank”. When they select blank, my code sets MeetingFrequency to “”. However, my report has a REF to the bookmark where the meeting title repeats on a later page, and when the bookmark is blank I get an error message where the REF field is (where I would like “nothing” to be). Is there a simple way that a very low-level VBA programmer such as myself can fix this problem? Replacing “””” with a single space in my code comes close, but it results in either too many or not enough spaces in the report.

    Viewing 4 reply threads
    Author
    Replies
    • #1250014

      You could try wrapping your REF in an {IF} field. Roughly: {IF {REF bmk}=TextOfErrorMessage “” {REF bmk}}.

    • #1250196

      Instead of:
      {IF{REF bmk}=TextOfErrorMessage “” {REF bmk}}.
      you could use:
      {IF{REF bmk} “Error!*” {REF bmk}}.
      Note the required space between the ” and the following expression (also required after an ‘=’).

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1251905

      Thanks! I’m sure both of your reasonings are fine, but I am not having any luck with the IF statements. I attached a file showing my attempt at both of your methods. Please change the extension from docx to dotm and double click to get the userform to popup.

    • #1251929

      I couldn’t open that document in Word 2003 for some reason. Here is a sample showing how you can use an IF field to test for the presence of a Bookmark. Press Alt+F9 to toggle between field results and field codes.

    • #1252006

      As a quick fix, you could leave one of the spaces out of the document itself and add one to each of your options, so you’d have ‘weekly ‘, ‘monthly ‘ and ‘ ‘ (or before the word, if that fits in better with your document). Then do the same at the other location where the info is used – leave a space out of the text and use the one in the options instead.

    Viewing 4 reply threads
    Reply To: Reply #1252006 in Empty bookmark gives REF field error

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

    Your information:




    Cancel