WD: Calculation Text Fields Within Forms Fail to Update

Last reviewed: February 11, 1998
Article ID: Q110014
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word 97 for Windows
  • Microsoft Word 98 Macintosh Edition

SYMPTOMS

Calculation text fields within forms are not updated automatically.

RESOLUTION

Word 97 for Windows or Word 98 Macintosh Edition

Use the Calculate On Exit option located in the Text Form Field Options dialog box. (To display this dialog box, click a form field, and click the Form Field Options button on the Forms toolbar.)

Word 6.x and 7.x

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code 'as is' without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

You cannot manually update a FORM field in these versions of Word. To update text fields which are defined as calculation fields, create a macro using the following steps:

  1. Create the following macro:

          Sub Main
             SetFormResult "text1"
          End Sub
    
       where "text1" represents the bookmark name used in the calculation form
       field.
    
       NOTE: If a bookmark in a calculation field expression contains a
       number, such as Q1 or UP1, the field will not update.  For a
       calculation field to update correctly, make sure the bookmark name
       does not contain numbers.
    
    

  2. Modify the form field options for the form field that you will exit before you enter the calculation form field. In the Text Form Field Options dialog box, under Run Macro On Exit, select the macro you created in step 1 and then click OK.

MORE INFORMATION

The following is a quick macro that serves as a generic for forms. It can be used in place of the macro shown in the Resolution section above.

   Sub MAIN
      For count = 1 To CountBookmarks()
         On Error Resume Next
         SetFormResult BookmarkName$(count)
         Err = 0
      Next
   End Sub

This macro attempts to update all bookmarks in the document. Calculation fields must have a bookmark (while other fields do not). If a bookmark resides within the protected document, an error occurs (which is caught by the third line of the sample above, and skipped).

This macro will give the impression of on-the-fly updating if it is added to each field; however, this will work slowly if your document contains a large number of calculation fields. If you need to update individual fields, use the SetFormResult command followed by the calculation field bookmark.


Additional query words: update updating field fields form forms bookmarks
formfield
Keywords : kbwordvba winword winword2 word6 word7 word8 word95 word97 macword98 kbcode kbmacro kbprg kbualink97
Version : 2.x 6.x 7.0a 97 98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 11, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.