just to be clear, my code was built with Service Pack 2 for ArcMap 10.1, so make sure you have installed Service Pack 2. I don't know that there is any effect of the Service Pack that might relate to your problem, but it is best to eliminate that possibility.The code I provided before only ran as a Field Calculation. It was not meant to be run as a Python script.To add the new subroutine you want that will fill in the Greatest Value field the code needs to be converted to a standalone script. A Field Calculation cannot efficiently summarize data and update records with the summary data, but a script can.So here is a script that should replace the Field Calculation that will assign with both the Sequence field values and the Greatest Value field values. You should no longer need the field calculation if you use this script. Make sure you customize the variable values for your data file name and path and for the field list so that it exactly matches your data set up:# Import the arcpy module
import arcpy
pStart = 1 # adjust start value, if required
pInterval = 1 # adjust interval value, if required
# Initialize the sequence number dictionary and the Route ID variables
seqDict = {}
CID = ""
# Assign data and field list variables.
# Customize these variable inputs for your specific data
myData = r"C:\MyPath\MyData.shp"
fields = ["CID", "SEQUENCE", "GREATEST"]
# Step 1 - Use an update cursor to assign Sequence numbers
rows = arcpy.da.UpdateCursor(myData, fields)
for row in rows:
if row[0] is None:
CID = "Null"
else:
CID = row[0]
if CID in seqDict:
seqDict[CID] = seqDict[CID] + pInterval
else:
seqDict[CID] = pStart
row[1] = seqDict[CID]
rows.updateRow(row)
del row
del rows
# Step 2 - Use an update cursor to assign the Greatest Value to all records
rows = arcpy.da.UpdateCursor(myData, fields)
for row in rows:
if row[0] is None:
CID = "Null"
else:
CID = row[0]
row[2] = seqDict[CID]
rows.updateRow(row)
del row
del rows
I also want to make sure you understand that this code will only work if it runs on every record in your data and that it will overwrite any previously assigned sequence numbers if any records have changed. To make the script continue any preexisting sequence numbering from any previous run of the tool the code would have to be changed to split Step 1 into two steps. First a search cursor would have to populate the sequence dictionary with the maximum sequence number for all existing sequences and then an update cursor would have to run to actually update the new records that did not have sequences assigned to continue those sequences or begin new sequences for new routes.