Sub JoinedFields() Dim pDoc As IMxDocument Set pDoc = ThisDocument Dim pFeatureLayer As IFeatureLayer Set pFeatureLayer = pDoc.FocusMap.Layer(0) Dim pFeat As IFeature Set pFeat = pFeatureLayer.FeatureClass.GetFeature(12) Dim pTable As ITable Dim pDisplayTable As IDisplayTable Set pDisplayTable = pFeatureLayer Set pTable = pDisplayTable.DisplayTable Dim pFields As IFields Dim pField As IField Set pFields = pTable.Fields For i = 0 To pFields.FieldCount - 1 Debug.Print pFields.Field(i).Name Next End Sub
For i = 0 To pDisplayTable.DisplayTable.Fields.FieldCount - 1Thanks for the suggestion Brian, but this does the same as the script in my original post - it just returns the field names, not the value for the selected record in each of those fields.
Debug.Print(pDisplayTable.DisplayTable.Fields.Field(i).Name)
Next
Sub JoinedFields()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Dim pFeatureLayer As IFeatureLayer
Set pFeatureLayer = pDoc.FocusMap.Layer(0)
Dim pFeat As IFeature
Set pFeat = pFeatureLayer.FeatureClass.GetFeature(12)
Dim pTable As ITable
Dim pDisplayTable As IDisplayTable
Set pDisplayTable = pFeatureLayer
Set pTable = pDisplayTable.DisplayTable
'Dim pFields As IFields
'Dim pField As IField
'Set pFields = pTable.Fields
'For i = 0 To pFields.fieldCount - 1
' Debug.Print pFields.Field(i).Name
'Next
Dim pTableCursor As ICursor
Dim pRow As IRow
Set pTableCursor = pTable.Search(Nothing, True)
Set pRow = pTableCursor.NextRow
Do Until pRow Is Nothing
Debug.Print pRow.Value(pTable.Fields.FindField("FeatureClass.FieldName")) 'fully qualified field name from joined table
Set pRow = pTableCursor.NextRow
Loop
End Sub
Dim pTableCursor As ICursor
Dim pRow As IRow
Set pTableCursor = pTable.Search(Nothing, True)
Set pRow = pTableCursor.NextRow
Do Until pRow Is Nothing
Debug.Print pRow.Value(pTable.Fields.FindField("FeatureClass.FieldName")) 'fully qualified field name from joined table
Set pRow = pTableCursor.NextRow
Loop
End SubWow Jeff that gets me a LOT closer, thanks! 😄Public Sub GetLayerSelection() 'allows enumeration through all features selected from a particular layer 'to get all features regardless of what layer they are in, use IMap.SelectedFeatures Dim mxDoc As IMxDocument Set mxDoc = ThisDocument Dim fLayer As IFeatureLayer Set fLayer = mxDoc.SelectedLayer Dim fSel As IFeatureSelection Set fSel = fLayer Dim ss As ISelectionSet Set ss = fSel.SelectionSet Dim fCur As IFeatureCursor ss.Search Nothing, True, fCur Dim feat As IFeature Set feat = fCur.NextFeature Do Until feat Is Nothing Debug.Print feat.OID Set feat = fCur.NextFeature Loop End Sub
Dim pTableCursor As ICursor
Dim pRow As IRow
Set pTableCursor = pTable.Search(Nothing, True)
Set pRow = pTableCursor.NextRow
Dim fIndex as Long
fIndex = pTable.Fields.FindField("FeatureClass.FieldName") 'fully qualified field name from joined table
Do Until pRow Is Nothing
Debug.Print pRow.Value(fIndex) ' removes a hidden loop required to find the field
Set pRow = pTableCursor.NextRow
Loop