AnsweredAssumed Answered

Python Script just stopped working..totally stumped

Question asked by johncarr on Apr 18, 2013
Latest reply on Apr 18, 2013 by johncarr
Hey everyone, I have a simple script pasted below that searches through a field containing numbers (the field is type double) in a feature class and returns what would be the next highest unused number in the field. I ran this script probably 20 times yesterday and it worked fine, then all the sudden it stopped working and I started getting this error...

Runtime error
Traceback (most recent call last):
  File "<string>", line 10, in <module>
NameError: name 'AccessDBNo' is not defined

Any ideas? I've never had something work and then suddenly not work with no changes made to the script whatsoever.

import arcpy
from arcpy import env
env.workspace = r"Database Connections\PTWP_Base.sde\PTWP_BASE.DBO.Propose_Facilities"
fc = "PTWP_BASE.DBO.Eval_Seg"

numbers = []
rows = arcpy.SearchCursor(fc)
for row in rows:
    numbers.append(row.getValue(AccessDBNo))
del row
   
numbers.sort()

max = numbers[-1]

NextNo=max+1

arcpy.AddMessage("The next available project number is...")
arcpy.AddMessage(NextNo)

Outcomes