English

Bug: Calculate Field is failing when using join fields in the expression with PYTHON calculation types

Description

Calculate Field is failing when using join fields in the expression with PYTHON calculation types.

Example Code:

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()
gp.overwriteoutput = 1

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")

# Local variables...
population = "D:\\testdata\\Geodatabase.mdb\\population"
cities = "D:\\testdata\\Geodatabase.mdb\\cities"
Table_Name = "population_View"
population_View = "population_View"
population_View__2_ = "population_View"
population_View__3_ = "population_View"

# Process: Make Table View...
gp.MakeTableView_management(population, Table_Name, "", "", "CITY CITY VISIBLE;POP2007 POP2007 VISIBLE;Acres Acres VISIBLE")

# Process: Add Field...
gp.AddField_management(Table_Name, "Acres", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")

# Process: Add Join...
gp.AddJoin_management(population_View, "CITY", cities, "MB_NAME", "KEEP_ALL")

# Process: Calculate Field...
gp.CalculateField_management(population_View__2_, "population.Acres", "float(!SHAPE.AREA!/43560)", "PYTHON")

Cause

Python is interpreting the table name as a field name, and the field name as a parameter.

Workaround

Instead of using PYTHON syntax in the expression parameter, use VB (Visual Basic) syntax.

Example:

# Process: Calculate Field...
gp.CalculateField_management(population_View__2_, "population.Acres", "[SHAPE.AREA]/43560", "VB")

    Related Information