How to Correct IF Field Code Syntax in a Word Table
Question details
The user needs to correct the IF field code syntax in a Word table to properly evaluate numeric bookmark values.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Evaluating an IF field expression against a numeric bookmark inside a Word document table.
- Observed behavior
- The IF field returns an incorrect result because the numeric bookmark was evaluated as text due to being placed inside quotation marks.
Verify that your target bookmark contains only numbers without any extraneous spaces or text, as non-numeric characters will disrupt the mathematical evaluation in the field code.
Use Nested Field Codes Without Quotation Marks
Fix the IF field syntax by treating the bookmark as a numeric variable via a nested field, rather than enclosing it in quotation marks.
When comparing numerical values in Word IF fields, placing the bookmark name in quotation marks treats the value as a text string rather than an integer. This leads to incorrect logical comparisons. Instead, you must use a nested field code to pull the bookmark's raw numerical value directly into the IF statement.
Locate the malfunctioning IF field code in your Word table, highlight it completely, and delete it to start fresh.
Press Ctrl+F9 on your keyboard to insert the outer pair of field braces. They will appear with a gray highlight. Do not type curly brackets manually.
Type 'IF ' inside the newly created braces, then press Ctrl+F9 again to insert a second, nested pair of field braces inside the first pair.
Inside the inner braces, type your bookmark name (e.g., srsp_a1). Move your cursor outside the inner braces, but inside the outer braces, and type your condition and outputs (e.g., > 77 "GT" "LE"). The entire string should look like: { IF { srsp_a1 } > 77 "GT" "LE" }.
Right-click the field code and select 'Update Field', or simply press F9 on your keyboard to execute the code and display the correct logical result.

Easily Manage Field Codes and Bookmarks with WPS Writer
WPS Writer provides comprehensive support for document automation, including advanced nested field codes, bookmarks, and cross-references. It offers a lightweight and user-friendly interface to quickly evaluate complex logical formulas inside your document tables.
- 1. Open your document: Launch WPS Writer and open the document containing your tables and field codes.
- 2. Insert field braces: Use the Ctrl+F9 keyboard shortcut to instantly insert functional field brackets.
- 3. Type your logical expression: Input your IF logic and nested bookmarks directly within the brackets.
- 4. Update fields: Highlight the field code and press F9 to trigger the calculation and view the final output.

Frequently Asked Questions
Why is my IF field code displaying as text instead of calculating?
If your code displays as raw text, it means you likely typed standard curly brackets using your keyboard. You must delete them and recreate the brackets by pressing Ctrl+F9.
How can I toggle between viewing field codes and their results?
You can easily switch between viewing the underlying field codes and the calculated results by pressing Alt+F9 on your keyboard. This reveals all the nested structures in the document.
Can I use multiple conditions in a single IF field?
Yes, you can evaluate multiple conditions by nesting additional IF field codes inside the 'true' or 'false' output string sections of your primary IF field.




