AddField/Calculate Field Errors in Loop

Discussion created by BrokenLegMike on Sep 2, 2011
Latest reply on Sep 2, 2011 by BrokenLegMike
Hey everyone,

I am trying to test for a field called "SITE" in any annotation feature classes within a workspace (File gdb) I've been running a few scripts, but I keep getting hung up on the same error message:

ERROR 999999: Error executing function.
Expected end of statement
Failed to execute (CalculateField).

I have a feeling the addfield and calculate field do not like each other in the "else" portion of my loop. I've tried different loop types, but the same error keeps coming up. I did a quick model with these 2 tool and then exported to a python script and they seem to have worked there. Any suggestions?


import arcpy

from arcpy import env

env.workspace = r"Z:\ESRI\Figure_Sourcing\Figures\Geodatabase\D09_IF_PDA_CR.gdb"

SITE = "D09 Infill"

fcListAnno = arcpy.ListFeatureClasses("*", "Annotation")

for fcAnno in fcListAnno:
    print fcAnno
    fieldListAnno = arcpy.ListFields(fcAnno, "SITE")
    print fieldListAnno

    if not arcpy.Exists(fieldListAnno):
        print "Does not exists"
        arcpy.AddField_management(fcAnno, "SITE", "TEXT", "", "", 50)
        arcpy.CalculateField_management(fcAnno, "SITE", SITE, "VB", "")
        print "Exists"
        arcpy.CalculateField_management(fcAnno, "SITE", SITE, "VB", "")