Microsoft KB Archive/115607

{|
 * width="100%"|

WD97: How to Update Fields in a Protected Form

 * }

Q115607

-

The information in this article applies to:


 * Microsoft Word 97 for Windows

-

SUMMARY
Fields in a document protected for forms may not be updated when you fill out the form. This article describes four methods you can use to update regular fields or automatically insert and update the result of one form field into another area of a form.

Method 1: Use the "Calculate On Exit" Option
In Microsoft Word 97 for Windows, form fields include a "Calculate on exit" option. When you enable this option, fields and form fields can be updated in a protected form document. Fields not updated by this switch include:

  TOC PAGE INDEX PAGEREF BARCODE For additional information, please see the following article in the Microsoft Knowledge Base:

"Q157463 WD97: How to Use Calculate on Exit in a Forms Document"

Method 2: Use a Macro
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please see the following page on the World Wide Web:

"http://www.microsoft.com/partner/referral/" For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

"http://support.microsoft.com/directory/overview.asp"

The following macro can be used as an on-exit macro for the first form field called "Text1" so that the information entered into this field will automatically appear in the form field called "Text2." Alternatively, the macro can be used as an on-entry macro for the second form field called Text2. When you tab to this second field, the result of the first form field is placed automatically as the field result of this second field.

Sub OnExitMacroExample With ActiveDocument .FormFields("Text2").Result = .FormFields("Text1").Result End With End Sub In this example, "Text1" and "Text2" are bookmarks. The Text1 bookmark represents the field that contains the information you want to automatically appear in the field represented by the Text2 bookmark.

For each field that receives the information automatically, clear the Fill- In Enabled check box in the Text Form Field Options dialog box. This minimizes the chance of accidentally modifying the field result.

Method 3: Reference a Form Field Entry Elsewhere in a Document
There may be times that you may want to reference a form field entry elsewhere in a document.

To repeat a form field entry using a reference field, follow these steps:


 * 1) Position the insertion point where you want the data to be repeated.

NOTE: The document (or section where the insertion point is) must be unprotected to insert a field.
 * 1) On the Insert menu, click Field and select REF from the Field Name list.
 * 2) In the Field Code box, insert the bookmark name (for example, text1) that represents the field into which you are entering the data. Click OK.

The REF field must be updated to display and print the text. An update will include all fields such as DATE and TIME. There are two ways to update fields in the protected area of your form:

 If the form will be a printed form, you can have the REF fields update when you print the document. On the Tools menu, click Options, select the Print tab, and select the Update Fields check box. When you select this option, fields may not be updated on the screen, but Word will update them properly when you print the document.  If you need all fields to be updated on the screen as you fill out the form, including fields not updated using the "Calculate on exit" option as described in Method 1, use the following macro as the On exit macro for your form field(s): Sub UpdateAllFields Dim aStory As Range Dim aField As Field For Each aStory In ActiveDocument.StoryRanges For Each aField In aStory.Fields aField.Update Next aField Next aStory End Sub 

NOTE: Because this exit macro may cause a slight delay on some computers, you may opt to select the "Update Fields on printing" option if this will be a printed form. You may also opt to choose the "Calculate on exit" option as described in Method 1.

Method 4: Place the REF Field in an Unprotected Section of the Document
If you choose this option, the macro will update the fields in the unprotected section or you can create a separate exit macro to go to that specific field and update it.

To place REF fields in unprotected sections of your document, follow these steps:


 * 1) Insert continuous section breaks above and below the REF fields.
 * 2) On the Tools menu, click Protect Document.
 * 3) Click Sections.
 * 4) Select the sections you want to have protected. Click OK.

For more information on using a REF field to reference a list box, please see the following articles in the Microsoft Knowledge Base:

"Q114237 WD: REF Field Creates Duplicate Drop-Down List in Protected Form" "Q117209 WD: How to Create a Form That Updates Automatically" Additional query words: forms formfield ref unprotect wordbasic vba

Keywords : kbdta kbmacroexample kbfield word97 kbform

Issue type : kbhowto

Technology : kbWordSearch kbWord97 kbWord97Search kbZNotKeyword2