HOW TO
Instructions provided describe how to label a related table using Python. There is no 'out-of-the-box' functionality to label a related table.
Note: A basic understanding of Python functions and search cursors is needed.
The code below creates a FindLabel Python function. Relates are not created, but the two key fields are compared in a double iteration.
def FindLabel ([keyField], [FirstLabel]):
import arcpy
key1 = [keyField] # Key field in feature class
key2 = "ID" # Key field in related table
L = [FirstLabel] # Label field in feature class
L2 = "Label2" # Label field in related table
myDataTable = r"<path-to-related-table>" # Path to related table
cur = arcpy.da.SearchCursor(myDataTable, [key2, L2])
for row in cur:
if str(key1) == str(row[0]):
L = L + " " + str(row[1])
return L
Article ID: 000012230
Get help from ArcGIS experts
Start chatting now