Programmatically access joined fields using VBA and ArcObjects

Last Published: April 25, 2020


This article describes how to access joined fields of a feature layer. Joined fields are contained in the display table.


  1. Start ArcMap.
  2. Open the Visual Basic Editor.

    In ArcMap, select Tools > Macros > Visual Basic Editor.

  3. In the Project Explorer window, expand Project.mxt and select ArcMap Objects > ThisDocument then right-click and select View Code.
    [O-Image] Visual Basic Project  Explorer
    Code in ThisDocument module will only run in the current map document. To store the code in all your map documents, open the Normal.mxt ThisDocument code module.

  4. Paste the following code into the code module.

    Sub AccessJoinedFields()
    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
    End Sub

  5. Close the Visual Basic Editor.
  6. Run the code.

    A. Click Tools > Macros > Macros to display the Macros dialog box.
    B. Select a macro and click Run.

Article ID:000004936

  • ArcMap 9 x
  • ArcMap 8 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options