Using arcpy.SelectLayerBy Attribute_management causing ArcMap 10.0.2 to freeze

787
2
09-27-2011 06:27 AM
TimLangner
Occasional Contributor III
Hi there

I'm running ArcMap 10.0.2 and trying to execute the following command in the Python window but it keeps causes ArcMap to freeze.
arcpy.SelectLayerByAttribute_management ("Full area polygons layer outline only v5", "NEW_SELECTION", " [AREA_NAME] = 'AREA 3' ")
Does anyone know what I might be doing wrong? I'm I missing out a stage. I've not typed any other command along with it.

If I do the same by using the Select by attribute interactive window, it doesn't freeze.

Kind regards

Tim
Tags (2)
0 Kudos
2 Replies
MathewCoyle
Frequent Contributor
I'd wager it has something to do with the square brackets around your field name. Try \"AREA_NAME\" instead.

Edit: I forgot personal GDB need those, Esri hates personal GDB so migrate while you can.
0 Kudos
TimLangner
Occasional Contributor III
Hi Matt

Your quite right. It was that. I was using the syntax for personal geodatabases when I'm working with an SDE geodatabase. My revised code is:

arcpy.SelectLayerByAttribute_management ("Full area polygons layer outline only v5", "NEW_SELECTION", """ [AREA_NAME] = 'AREA 3' """)


Saying that after I got my new code to work and it had selected the features, ArcMap shortly froze. However on restarting ArcMap it then worked, after several error messages about valid index range being passed. That may be a freak event, as I'm new to working with the Python window.

Kind regards
0 Kudos