My program is to find missing records when comparing to layers inside an mxd and then highlight the ones that are missing. For example, if one layer has 105H1 then the other layer should have it if not then it highlights that record to alert the user it is missing in the other layer. Right, now it is highlighting ones that are missing but also highlighting random ones that are in both layers??? I think my problem is the loop at the bottom of my program but a) I'm not sure and b) I don't know how to fix it.
import arcpy, traceback mxd = arcpy.mapping.MapDocument("CURRENT") lstLayers = arcpy.mapping.ListLayers(mxd) flayer = arcpy.mapping.ListLayers(mxd, "AADT") alayer = arcpy.mapping.ListLayers(mxd, "AADTAnnoLabel") FRows = arcpy.SearchCursor(flayer) ARows = arcpy.SearchCursor(alayer) ffields = arcpy.ListFields(flayer, "FLAG", "String") afields = arcpy.ListFields(alayer, "TFLAG", "String") FList =  AList =  for row in FRows: Fvalue = row.getValue("FLAG") FList.append(str(Fvalue)) for row in ARows: Avalue = row.getValue("TFLAG") AList.append(str(Avalue)) matched = set(FList) & set(AList) for x in matched: exp = '"FLAG" = ' + "'" + x + "'" arcpy.SelectLayerByAttribute_management("AADT", "ADD_TO_SELECTION", exp) arcpy.SelectLayerByAttribute_management("AADT", "SWITCH_SELECTION")