Hi, What version of Arc are you using? I did get this working based on your example. There may have been some small syntax errors in your code. Try writing your lyr and qry like this: [HTML] #lyr = "C:\Projects\BranchMapping\dev\src\GP_Tasks\ppOwner.lyr" lyr = r"C:\Projects\BranchMapping\dev\src\GP_Tasks\BRANCHES.lyr" #qry = "KeyInstn = 4001616" # D qry = "\"KeyInstn\" = 4001616" # VABK [/HTML] There is a little more info on correct syntax within a where clause for Python here: http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000071000000 And the error that you are receiving when trying to use "SelectLayerByAttribute" may be fixed by using "MakeFeatureLayer" first which works as input for the Select Layer by Attribute tool. So basically something like this: [HTML] # Import system modules import sys, string, os, arcpy #lyr = "C:\Projects\BranchMapping\dev\src\GP_Tasks\ppOwner.lyr" lyr = r"C:\Projects\BranchMapping\dev\src\GP_Tasks\BRANCHES.lyr" #qry = "KeyInstn = 4001616" # D qry = "\"KeyInstn\" = 4001616" # VABK # You do need to make feature layer to use as input select layer by attribute arcpy.MakeFeatureLayer_management(lyr,"lyr") arcpy.SelectLayerByAttribute_management("lyr", "NEW_SELECTION", qry) result = arcpy.GetCount_management("lyr") count = int(result.getOutput(0)) arcpy.AddMessage(str(count)) [/HTML] I hope that helps!
... View more