As Paul said,
you cannot set this up using any of Word's dialogs. It has to be typed into the document and you need to
use Ctrl+F9 to insert the field braces.
Your field does not look like his. It does not have the same structure.
His: {IF{STYLEREF "StyleName"}<> "Error!*" {STYLEREF "StyleName"}}
Yours originally: {IF STYLEREF 1 = "Error!*", "", STYLEREF 1}
Yours from the dialog: {IF STYLEREF "Heading 1" <> "Error!*" "" STYLEREF "Heading 1"}
If you edit the field you have from the dialog and select: STYLEREF "Heading 1"
then press Ctrl+F9 to make that a StyleRef field, it should work. Right now, it is being read as text rather than as the field.
If you used Alt+F9 to toggle field code display, after you are done editing the field, remember to toggle display of field results back on. If you used Shift+F1 to toggle an individual field, press F9 to update the field.
Note the missing braces, and the added commas. Your original field does not follow the required
field syntax although it would be good as an Excel function or in vba. Your second does not have the nested
StyleRef fields. Remember, too, that the spaces are important.