<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get a value from a joined field in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330549#M8577</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Just a note to improve performance on a portion of the code Jeff provided. Make it a practice to get the index of any field outside of the loops you create and directly use the field index in the loop. The FindField operation does a schema search loop that really only needs to be done once outside of your loop. Repeating loops within loops drags down performance. Using the index value directly inside the loop acts like direct array access to the field and does not cause a secondary hidden loop to occur for every record your loop processes. (From best practices with cursors training at the ESRI conference). So the sample code should be revised as follows:&lt;BR /&gt; &lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableCursor As ICursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pRow As IRow
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTableCursor = pTable.Search(Nothing, True)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fIndex as Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; fIndex = pTable.Fields.FindField("FeatureClass.FieldName") 'fully qualified field name from joined table
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pRow Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pRow.Value(fIndex) ' removes a hidden loop required to find the field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;/PRE&gt; &lt;BR /&gt;Hope this helps.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Good point Richard.&amp;nbsp; It might also be worth mentioning to check if fIndex is &amp;lt;&amp;gt; -1 (i.e. the field name is not found in the feature class or table) before using it, to avoid an automation error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 15:39:06 GMT</pubDate>
    <dc:creator>JeffMatson</dc:creator>
    <dc:date>2021-12-11T15:39:06Z</dc:date>
    <item>
      <title>Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330539#M8567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a tool that selects two features (different feature-classes), gets a value from a specific field in feature 1 and puts it into a specific field in feature 2. This mostly does what I want, except I would like to get the value from a field from a joined table, but the tool won't work on a joined field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I get it to use a join field value? I went hunting for some code that looks at joined fields, and found something in the old forums that will give me all the field names, including the joined fields, but I can't find an option to get the value from a field. Is it possible to change this script somehow to give me the values from those fields?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;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
&amp;nbsp; Debug.Print pFields.Field(i).Name
Next
End Sub
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had thought I could do something like "Debug.Print pFields.Field(i).Value" but that's not an option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Aug 2010 19:19:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330539#M8567</guid>
      <dc:creator>MikeLouwrens</dc:creator>
      <dc:date>2010-08-05T19:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330540#M8568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Im beginner in VBA , but i think you could start thinking about ifeature interface&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriGeoDatabase/IFeature.htm"&gt;http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriGeoDatabase/IFeature.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;there you can get value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;maybe this help for start&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;have a great day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Aug 2010 04:59:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330540#M8568</guid>
      <dc:creator>DanielTuracek</dc:creator>
      <dc:date>2010-08-06T04:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330541#M8569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could use a IQueryDef object to perform your own join. I'm not familiar with VB, but the general aproach is to call IFeatureWorkspace.CreateQueryDef to get a QueryDef object, where you can set the table names to join in a comma seperated string (like pQueryDef.Tables = "Table1, Table2")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;define join and filter attributes with the where clause (like pQueryDef.WhereClause = "Table1.key = 'KeyOfCurrentRow' and Table1.key = Table2.key") and maybe set the IQueryDef.Subfields to only get the values you need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;After doing so, a call to pQueryDef.Evaluate returns an ICursor with the resulting values of both tables. In other words: You define the parameters for a simple SQL Select-statement and get the result.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Aug 2010 09:00:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330541#M8569</guid>
      <dc:creator>JanDuske</dc:creator>
      <dc:date>2010-08-09T09:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330542#M8570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For i = 0 To pDisplayTable.DisplayTable.Fields.FieldCount - 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Debug.Print(pDisplayTable.DisplayTable.Fields.Field(i).Name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Aug 2010 15:58:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330542#M8570</guid>
      <dc:creator>BrianBottoms</dc:creator>
      <dc:date>2010-08-09T15:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330543#M8571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;For i = 0 To pDisplayTable.DisplayTable.Fields.FieldCount - 1&lt;BR /&gt;Debug.Print(pDisplayTable.DisplayTable.Fields.Field(i).Name)&lt;BR /&gt;Next &lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;Thanks 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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lets say I have a field DIAM that stores the diameter of a pipe. The script I gave tells me there is a field DIAM, but what I want is to know that for the selected field, the value of DIAM is 200 - I can do this on a GDB field, but I can't figure out how to do it on a joined field, all I ever get is the field name, and not the specific value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Sep 2010 18:47:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330543#M8571</guid>
      <dc:creator>MikeLouwrens</dc:creator>
      <dc:date>2010-09-02T18:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330544#M8572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try looping through the rows in the table to get the values.&amp;nbsp; Just change "FeatureClass.FieldName" to match the table and field you want to see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Sub JoinedFields()
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pDoc As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pDoc = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeatureLayer As IFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeatureLayer = pDoc.FocusMap.Layer(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeat As IFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeat = pFeatureLayer.FeatureClass.GetFeature(12)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTable As ITable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pDisplayTable As IDisplayTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pDisplayTable = pFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTable = pDisplayTable.DisplayTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Dim pFields As IFields
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Dim pField As IField
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Set pFields = pTable.Fields
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'For i = 0 To pFields.fieldCount - 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; '&amp;nbsp; Debug.Print pFields.Field(i).Name
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Next
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableCursor As ICursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pRow As IRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTableCursor = pTable.Search(Nothing, True)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pRow Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pRow.Value(pTable.Fields.FindField("FeatureClass.FieldName"))&amp;nbsp; 'fully qualified field name from joined table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop
End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:38:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330544#M8572</guid>
      <dc:creator>JeffMatson</dc:creator>
      <dc:date>2021-12-11T15:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330545#M8573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableCursor As ICursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pRow As IRow
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTableCursor = pTable.Search(Nothing, True)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pRow Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pRow.Value(pTable.Fields.FindField("FeatureClass.FieldName"))&amp;nbsp; 'fully qualified field name from joined table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop
End Sub&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;Wow Jeff that gets me a LOT closer, thanks! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any suggestions on how to get it to report for only the selected record (either using the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Set pFeat = pFeatureLayer.FeatureClass.GetFeature(12) &lt;/SPAN&gt;&lt;SPAN&gt;from in my code, or an actual selected feature), rather than looping through all records? I know I could probably put a Query filter into the cursor, but is there a quicker/easier way that you know of?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:38:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330545#M8573</guid>
      <dc:creator>MikeLouwrens</dc:creator>
      <dc:date>2021-12-11T15:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330546#M8574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is a sample that loops through the selected features from a particular layer (in this case the selected layer in the table of contents):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;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
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim mxDoc As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set mxDoc = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fLayer As IFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set fLayer = mxDoc.SelectedLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fSel As IFeatureSelection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set fSel = fLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim ss As ISelectionSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set ss = fSel.SelectionSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fCur As IFeatureCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; ss.Search Nothing, True, fCur
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim feat As IFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set feat = fCur.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until feat Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print feat.OID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set feat = fCur.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop
End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330546#M8574</guid>
      <dc:creator>JeffMatson</dc:creator>
      <dc:date>2021-12-11T15:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330547#M8575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;of course, thanks Jeff&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Sep 2010 22:29:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330547#M8575</guid>
      <dc:creator>MikeLouwrens</dc:creator>
      <dc:date>2010-09-02T22:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330548#M8576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just a note to improve performance on a portion of the code Jeff provided.&amp;nbsp; Make it a practice to get the index of any field outside of the loops you create and directly use the field index in the loop.&amp;nbsp; The FindField operation does a schema search loop that really only needs to be done once outside of your loop.&amp;nbsp; Repeating loops within loops drags down performance.&amp;nbsp; Using the index value directly inside the loop acts like direct array access to the field and does not cause a secondary hidden loop to occur for every record your loop processes.&amp;nbsp; (From best practices with cursors training at the ESRI conference).&amp;nbsp; So the sample code should be revised as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableCursor As ICursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pRow As IRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTableCursor = pTable.Search(Nothing, True)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fIndex as Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; fIndex = pTable.Fields.FindField("FeatureClass.FieldName") 'fully qualified field name from joined table
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pRow Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pRow.Value(fIndex) ' removes a hidden loop required to find the field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330548#M8576</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T15:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330549#M8577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Just a note to improve performance on a portion of the code Jeff provided. Make it a practice to get the index of any field outside of the loops you create and directly use the field index in the loop. The FindField operation does a schema search loop that really only needs to be done once outside of your loop. Repeating loops within loops drags down performance. Using the index value directly inside the loop acts like direct array access to the field and does not cause a secondary hidden loop to occur for every record your loop processes. (From best practices with cursors training at the ESRI conference). So the sample code should be revised as follows:&lt;BR /&gt; &lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableCursor As ICursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pRow As IRow
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTableCursor = pTable.Search(Nothing, True)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fIndex as Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; fIndex = pTable.Fields.FindField("FeatureClass.FieldName") 'fully qualified field name from joined table
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pRow Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pRow.Value(fIndex) ' removes a hidden loop required to find the field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;/PRE&gt; &lt;BR /&gt;Hope this helps.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Good point Richard.&amp;nbsp; It might also be worth mentioning to check if fIndex is &amp;lt;&amp;gt; -1 (i.e. the field name is not found in the feature class or table) before using it, to avoid an automation error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330549#M8577</guid>
      <dc:creator>JeffMatson</dc:creator>
      <dc:date>2021-12-11T15:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330550#M8578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK thanks all for you help, much appreciated &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've got something working now, although is a little slow... can I have done this a bit more efficiently?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Public Sub GetLayerSelection2()
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMxDoc As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMxDoc = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFLayer As IFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFLayer = pMxDoc.FocusMap.Layer(0) 'Get first layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFSel As IFeatureSelection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFSel = pFLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pSelSet As ISelectionSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pSelSet = pFSel.SelectionSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFCursor As IFeatureCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; pSelSet.Search Nothing, True, pFCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pCount As Integer
&amp;nbsp;&amp;nbsp;&amp;nbsp; pCount = pSelSet.count
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; If pCount &amp;gt; 5 Then 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "Too many features selected.&amp;nbsp; Please select 5 or less." 'Is quite slow, so don't run if lots of features
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeature As IFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeature = pFCursor.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pDisplayTable As IDisplayTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pDisplayTable = pFLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTable As ITable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTable = pDisplayTable.DisplayTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim strQuery As String
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pQFilter As IQueryFilter
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pQFilter = New QueryFilter
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableCursor As ICursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableIndex As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; pTableIndex = -1
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeatureIndex As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; pFeatureIndex = -1
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pFeature Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If pFeatureIndex = -1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFeatureIndex = pFeature.Fields.FindField("COMPKEY")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strQuery = "COMPKEY = " &amp;amp; pFeature.Value(pFeatureIndex) 'Use join field (COMPKEY) to find matching record in table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pQFilter.WhereClause = strQuery
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTableCursor = pTable.Search(pQFilter, False)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pRow As IRow
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If pTableIndex = -1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pTableIndex = pTable.Fields.FindField("SERVSTAT") ' Field to be found in join table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pRow Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pRow.Value(pTableIndex) ' report value of field in join table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeature = pFCursor.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
End Sub&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330550#M8578</guid>
      <dc:creator>MikeLouwrens</dc:creator>
      <dc:date>2021-12-11T15:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330551#M8579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can tighten up the loop a little by taking out the field tests outside of the loops as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Dim pTableIndex As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pTableIndex = pTable.Fields.FindField("SERVSTAT") ' Field to be found in join table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If pTableIndex = -1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox "SERVSTAT field not found.&amp;nbsp; Exiting Sub."
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeatureIndex As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFeatureIndex = pFeature.Fields.FindField("COMPKEY")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If pFeatureIndex = -1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox "COMPKEY field not found.&amp;nbsp; Exiting Sub."
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pFeature Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strQuery = "COMPKEY = " &amp;amp; pFeature.Value(pFeatureIndex) 'Use join field (COMPKEY) to find matching record in table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pQFilter.WhereClause = strQuery
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pTableCursor = pTable.Search(pQFilter, False)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pRow As IRow
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pRow Is Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pRow.Value(pTableIndex) ' report value of field in join table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeature = pFCursor.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330551#M8579</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T15:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330552#M8580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried your code and don't understand why it works for you at all.&amp;nbsp; When I used it on a joined feature layer I got errors when I tried to just use a field name in the join table.&amp;nbsp; I had to use the fully qualified table name and field name to obtain the display table field index and a correctly formatted query where clause inside of the loop to access the joined field name.&amp;nbsp; I could not just use an unqualified field name as you seem to be doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am assuming you intend to write data to the parent feature class and not just read the data of the joined table.&amp;nbsp; Otherwise, if all you wanted to do was read data you should be able to just use the display table without having to use the parent feature class and a pair of embedded loops on the parent feature class and on the display table.&amp;nbsp; To just&amp;nbsp; read data you should bypass the FeatureSelection and just set the SelectionSet to the DisplaySelectionSet of the display table and loop through it to get your key and joined field together (using the fully qualified table name and field name of the joined table).&amp;nbsp; So what is this code really supposed to end up doing for you?&amp;nbsp; If you need to use it to write to the parent table (or you actually have a 1:M or M:M relationship), then the embedded loops are probably necessary.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 05:14:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330552#M8580</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2010-10-05T05:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330553#M8581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have revised your code to make it more efficient.&amp;nbsp; Your code is slow because it uses repeated queries inside of a loop (it also was repeatedly doing a Dim of the Row variable inside the loop as well, which is a big no no.&amp;nbsp; Never do a Dim inside of a loop).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I realized that since you are accessing the same SelectionSet for the same parent feature class through the same layer that you do not need to use a queryfilter in the loop to synchronize the reading of the parent feature class and the joined table.&amp;nbsp; To prove that the cursors on the unjoined featureclass and the joined displaytable are running in synch, I substituted reading the parent table ObjectID feilds in the code below.&amp;nbsp; You can revise this code back to replacing the fields with your original fields (again if all you want to do is just read the joined data, just use the display table SelectionSet together with either the ParentTableName.FieldName or JoinTableName.FieldName formats for the fields you want to read).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now ideally this code could be further modified to use an efficient method that would substitute an update cursor for reading through the SelectionSet of the parent feature class instead of using a search cursor.&amp;nbsp; That way the code would allow reading of data from the joined displaytable and writing to the features of the parent FeatureClass in a single pass, with efficiency that is similar to using a FieldCalculator with a VBA or VB Script expression on a joined table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Public Sub GetLayerSelection2()
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMxDoc As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pMxDoc = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFLayer As IFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFLayer = pMxDoc.FocusMap.Layer(0) 'Get first layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pDisplayTable As IDisplayTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pDisplayTable = pFLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; If Not TypeOf pDisplayTable.DisplayTable Is IRelQueryTable Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "Feature Layer is not joined!&amp;nbsp; Exiting Sub."
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pSelSet As ISelectionSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pSelSet = pDisplayTable.DisplaySelectionSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pCount As Long ' Use Integer only if this is VB.Net and not VBA.
&amp;nbsp;&amp;nbsp;&amp;nbsp; pCount = pSelSet.Count
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; If pCount &amp;gt; 5 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "Too many features selected.&amp;nbsp; Please select 5 or less." 'Was quite slow, but now probably no longer necessary
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableCursor As ICursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; pSelSet.Search Nothing, True, pTableCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pRow As IRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFSel As IFeatureSelection
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFSel = pFLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pSelSet2 As ISelectionSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pSelSet2 = pFSel.SelectionSet
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFCursor As IFeatureCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; pSelSet2.Search Nothing, True, pFCursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeature As IFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeature = pFCursor.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pTableIndex As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; pTableIndex = pDisplayTable.DisplayTable.Fields.FindField("ParentTableName.OBJECTID") ' Substitute the actual ParentTableName or use JoinTableName.FieldName
&amp;nbsp;&amp;nbsp;&amp;nbsp; If pTableIndex = -1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "ParentTableName.OBJECTID Field Not Found! Exiting Sub." ' Substitute the appropriate message.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFeatureIndex As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; pFeatureIndex = pFeature.Fields.FindField("OBJECTID")
&amp;nbsp;&amp;nbsp;&amp;nbsp; If pFeatureIndex = -1 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "OBJECTID Field Not Found! Exiting Sub."
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until pFeature Is Nothing ' Keep your loop as tight as possible and do not do Dim statements inside of it.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print pFeature.Value(pFeatureIndex) &amp;amp; " = " &amp;amp; pRow.Value(pTableIndex) ' report value of field in join table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pRow = pTableCursor.NextRow
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pFeature = pFCursor.NextFeature
&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop
End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:39:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330553#M8581</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T15:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330554#M8582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Take a look at the IGeoFeatureLayer interface for another method to get at the values on joined fields (IGeoFeatureLayer.SearchDisplayFeatures). It might be an easier approach.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 17:03:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330554#M8582</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-10-05T17:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330555#M8583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Take a look at the IGeoFeatureLayer interface for another method to get at the values on joined fields (IGeoFeatureLayer.SearchDisplayFeatures). It might be an easier approach.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sean:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I looked at that interface, but that method is available already on the IDisplayTable and the help for IGeoFeatureLayer suggest using the IDisplayTable interface since it is more generic (it works with joined featureclasses and standalone tables).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other disadvantage of the IGeoFeatureLayer is that it requires the construction of a queryfilter and has no direct access to the existing SelectionSet for the layer.&amp;nbsp; The code as writen is using whatever is already selected and the IDisplayTable provides fairly direct access to the SelectionSet for both the unjoined parent featureclass (or StandaloneTable) and the joined table data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What would be most useful at this point is a suggestion for the most direct way to transfer the records of a SelectionSet over to an Update Cursor without constructing a potentially huge whereclause.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 17:29:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330555#M8583</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2010-10-05T17:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330556#M8584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think if you give &lt;/SPAN&gt;&lt;STRONG&gt;nothing &lt;/STRONG&gt;&lt;SPAN&gt;as the queryfilter to ISelectionSet.Search, it will return all the records as a cursor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 18:16:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330556#M8584</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-10-05T18:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330557#M8585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I tried your code and don't understand why it works for you at all. When I used it on a joined feature layer I got errors when I tried to just use a field name in the join table. I had to use the fully qualified table name and field name to obtain the display table field index and a correctly formatted query where clause inside of the loop to access the joined field name. I could not just use an unqualified field name as you seem to be doing.&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;My join table is a standalone SQL table in a non-SDE database.&amp;nbsp; I've found that if I join to a table within an SDE database then I have to use fully qualified table/field names, but not if to a non-SDE table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am assuming you intend to write data to the parent feature class and not just read the data of the joined table. Otherwise, if all you wanted to do was read data you should be able to just use the display table without having to use the parent feature class and a pair of embedded loops on the parent feature class and on the display table. To just read data you should bypass the FeatureSelection and just set the SelectionSet to the DisplaySelectionSet of the display table and loop through it to get your key and joined field together (using the fully qualified table name and field name of the joined table). So what is this code really supposed to end up doing for you? If you need to use it to write to the parent table (or you actually have a 1:M or M:M relationship), then the embedded loops are probably necessary.&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;What I've got is a tool (in .Net) that loops through selected points, creates a line from each point, and then takes some attributes from that point and writes it to the line.&amp;nbsp; The join is on the point feature class, and I am wanting to take a value from the join table and put it on the line.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 18:41:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330557#M8585</guid>
      <dc:creator>MikeLouwrens</dc:creator>
      <dc:date>2010-10-05T18:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value from a joined field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330558#M8586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;My join table is a standalone SQL table in a non-SDE database.&amp;nbsp; I've found that if I join to a table within an SDE database then I have to use fully qualified table/field names, but not if to a non-SDE table.&lt;BR /&gt; &lt;BR /&gt;What I've got is a tool (in .Net) that loops through selected points, creates a line from each point, and then takes some attributes from that point and writes it to the line.&amp;nbsp; The join is on the point feature class, and I am wanting to take a value from the join table and put it on the line.&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Mike.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried your code with a file geodatabase and it requried the fully qualified table name and field name, so the behavior is not limited to an SDE geodatabase.&amp;nbsp; But whatever works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since your line features are not part of the code you have written and all your code accesses currently is the point feature class, you do not need the emedded loops to read the joined table.&amp;nbsp; You also will not need embedded loops if you are going to simply construct one line from the points, since you would then just be writing to one feature and you can access all of the fields you need including the shape field of the parent table from the ICursor object derived from the IDisplayTable.&amp;nbsp; However, if you are going to construct more than one line from a set of points based on some attrribute you would then need a set of embedded loops to control the creation of each line feature and the writing of the point attribute.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My latest code is writen with the intent of addressing the broader question that keeps coming up on the forum of how do you use an update cursor on a joined table.&amp;nbsp; It is very close to doing that if the SelectionSet of the parent Feature Class could be translated to an update cursor instead of a search cursor.&amp;nbsp; (It can be done by buiilding a where clause from the OID values, but that would entail an extra read of the data, which would be nice to avoid, as well as creation of a potentially very long clause if many features are selected).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Oct 2010 19:00:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-a-value-from-a-joined-field/m-p/330558#M8586</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2010-10-05T19:00:13Z</dc:date>
    </item>
  </channel>
</rss>

