I would like to select records based on one field of the highest OBJECTID value. So I am first creating the selection of the highest OBJECTID to obtain the value CountyFFY for that record. Then I am creating a selection on a feature layer (created from the same file) to select all the records with the same CountyFFY. However when I use the count method is showing 0 values and I can't see the feature layer in the table of contents. I don't get any error messages. Do you guys have any idea why this is happening? Why is it not selecting? Is there a problem with my query expression? Thank you
Code:
maxValue3 = arcpy.SearchCursor("Stewardship", "", "", "", "OBJECTID D").next().getValue("OBJECTID")
arcpy.SelectLayerByAttribute_management("Stewardship", "NEW_SELECTION", "OBJECTID = " + str(maxValue3))
arcpy.AddMessage(maxValue3)
maxValuestr3 = str(maxValue3)
trows = arcpy.SearchCursor("Stewardship")
for row in trows:
FFYtxt = row.getValue("FFY")
Countytxt = row.getValue("County")
SequenceNum = row.getValue("SequenceNumber")
FFYCountytxt = row.getValue("FFYCounty")
arcpy.AddMessage(FFYCountytxt)
lyr = arcpy.mapping.ListLayers(arcpy.mapping.MapDocument('CURRENT'), 'Stewardship')[0]
arcpy.MakeFeatureLayer_management(lyr.dataSource, "TMP")
arcpy.SelectLayerByAttribute_management("TMP", "NEW_SELECTION", "FFYCounty = " + FFYCountytxt)
result = int(arcpy.GetCount_management("TMP").getOutput(0))
arcpy.AddMessage(result)