<?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: Sum Column in Related Table and Populate EDITFORM Field in ArcPad Questions</title>
    <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260237#M1893</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason- &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You are correct, I am using my own primary key (NEWKEY). I have always been a little spooked by ObjectIDs....call me paranoid if you like. Try using Fields("AXF_ObjectID").value. This should return the value of your AXF_ObjectID that you can store in a variable. Then in your SQL statment add the where clause like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "......where [AXF_ObjectID] = " + CStr(variable)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Mar 2011 13:45:41 GMT</pubDate>
    <dc:creator>EricMcPhee</dc:creator>
    <dc:date>2011-03-07T13:45:41Z</dc:date>
    <item>
      <title>Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260231#M1887</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;BR /&gt;&lt;SPAN&gt;I have a point feature with a related table. The user populates the related table within the field form. One of the columns is called "volume_removed". The user will enter multiple rows until the parameters stabilize. There could be as many as 20 rows (or more). I have a field, not in the related table, on the last page of the form called "Total_Volume_Removed". I would like to create a script that would populate this field from the sum of the "volume_removed" field in the related table. I do not know how to call values from the related tables to create a script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;JC&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 16:18:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260231#M1887</guid>
      <dc:creator>jeffclonts</dc:creator>
      <dc:date>2011-03-02T16:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260232#M1888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ESRI is supposedly getting back to me on a very similar issue. Basically, you need to be able to access the recordset and filter it to obtain all of the records that are related to the current point. Then, basically you need a sum(volume_removed).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that I do not know how to access the recordset of a related table.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 20:11:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260232#M1888</guid>
      <dc:creator>JasonTipton</dc:creator>
      <dc:date>2011-03-02T20:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260233#M1889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you using shapefiles and related .dbfs or .AXF?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have had success querying a related table in .axf. The query is just a SQL statement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sub SummarizeTrees&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; dim DataSource &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; set DataSource = Map.Layers("MFIPlotsContractor").DataSource 'this is the feature(parent) table&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; dim query&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dim queryRows&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'this query will select the rows I want from the related table (ENVIRO_MFITREESCONTRACTOR)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query = "SELECT SUM(dbh) from ENVIRO_MFITREESCONTRACTOR where [NEWKEY] = " + CStr(Stand)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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 queryRows = DataSource.execute(query)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryrows.movefirst&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox "The Sum of DBH for Stand#" &amp;amp; CStr(Stand) &amp;amp; ":" &amp;amp; (Chr(13)) &amp;amp; queryRows.fields(1).value&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;end sub&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 13:38:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260233#M1889</guid>
      <dc:creator>EricMcPhee</dc:creator>
      <dc:date>2011-03-03T13:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260234#M1890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank You Thank You Thank You Thank You!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes. .axf. I figured that it would be something fairly simple like that. I just couldn't find any documentation for it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 18:36:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260234#M1890</guid>
      <dc:creator>JasonTipton</dc:creator>
      <dc:date>2011-03-03T18:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260235#M1891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;slcemcphee33&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot for your input. It worked great! I ended up creating a "Summarize" button on my form that will allow the user populate the Total Volume field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sub SummarizeVolume&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; dim DataSource, objControl, objPage&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; set DataSource = Map.Layers("Wells").DataSource&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objControl = ThisEvent.Object &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objPage = ThisEvent.Object.Parent &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; dim query&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; dim queryRows&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; query = "SELECT SUM(vol_removed) from TABLE_PARAMETERS" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; set queryRows = DataSource.execute(query)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; queryrows.movefirst&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; objPage.Controls("txtTotVolRemoved").Value = queryRows.fields(1).value&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;end sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You da man!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;jc&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 19:44:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260235#M1891</guid>
      <dc:creator>jeffclonts</dc:creator>
      <dc:date>2011-03-03T19:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260236#M1892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;jclonts, Hold on, I don't think you're out of the woods yet!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You have no WHERE in your SQL statement. That will give you the sum of all the volume removed from all your wells.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;so if you had a total of 10, 15 and 20 gallons removed from well 1, that would be 45. Then from well Two, 5 and 20 gallons for 25 gallons. Instead of return 25 on well Two, you will 10 + 15 + 20 + 5 + 20 = 70. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I assume that you are using the ObjectID for your relates. . . &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;slcemcphee33,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume that you are making your own Primary/Foreign Key "NewKey" that you store in the value Stand? I haven't reached that point yet. I am still using the ObjectID for my relationships which is scary in my opinion. The problem is that I can't figure out how to get the AXF_OBjectID for the current point to use in my WHERE statement. If you use fields(AXF_OBJECTID), it won't return anything.&amp;nbsp; I may have to just turn to using my own keys...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 15:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260236#M1892</guid>
      <dc:creator>JasonTipton</dc:creator>
      <dc:date>2011-03-04T15:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260237#M1893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason- &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You are correct, I am using my own primary key (NEWKEY). I have always been a little spooked by ObjectIDs....call me paranoid if you like. Try using Fields("AXF_ObjectID").value. This should return the value of your AXF_ObjectID that you can store in a variable. Then in your SQL statment add the where clause like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "......where [AXF_ObjectID] = " + CStr(variable)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2011 13:45:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260237#M1893</guid>
      <dc:creator>EricMcPhee</dc:creator>
      <dc:date>2011-03-07T13:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260238#M1894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Right, right. See it doesn't appear to create the AXF_ObjectID until it saves the point. Once you close the point and reopen it, you can query for AXF_ObjectID, but not before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, when you create your New_id for the feature class, does ArcPad maintain the relationship on the table side? (Do you have to set the foreign key = new_id or does it handle that?) And what are you using for your "newKey" so that if multiple users go out at the same time, they don't come back w/ duplicate newKeys?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2011 15:43:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260238#M1894</guid>
      <dc:creator>JasonTipton</dc:creator>
      <dc:date>2011-03-07T15:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260239#M1895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am working with pre-assigned plots (my points already exist), which are assingned a "newkey" value based upon which stand(polygon) they reside in. This is all done before it gets to ArcPad. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, in my geodatabase I have a point featureclass with all of my plots (which have their "newkey" and a PlotID pre-assigned) and Related Table that has PlotID as the foreginkey and a relationship class between the featureclass and standalone table. When a new Tree (related table row) is added, I copy the NEWKEY to the new related record and also assign a new TreeID, which is a sequential number. Since I have setup a relationship class in my Geodatabase, the software takes care of adding the PlotID to each new record added to the related table.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2011 16:35:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260239#M1895</guid>
      <dc:creator>EricMcPhee</dc:creator>
      <dc:date>2011-03-07T16:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sum Column in Related Table and Populate EDITFORM Field</title>
      <link>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260240#M1896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I see.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Before long, I plan on abandoning the OBJECTID as well. Not only do I not trust it, if you try and move the data, the objectID's get reordered so when ArcMap doesn't import your data for some reason, you have to change all of the pk/fk.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I found, is that you can always access the foreign key even before the original feature class is committed.&amp;nbsp; So, in the related form, I can query and find the information I need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my code to query and find how many related [Lithology] records there are and to increment that number by 1 to give me a [LithOrderNumber] starting with 1 instead of 0:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sub countRecords
Dim ds
Dim query
Dim qRows

Set ds = Map.Layers("FieldPoints").DataSource
set flds = ThisEvent.Object.Fields

fid = flds("FIELDPOINTS_ID").VALUE&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Sets fid to the fk
query = "SELECT COUNT(AXF_OBJECTID) FROM [LITHOLOGY] WHERE [FIELDPOINTS_ID] =" &amp;amp; fid
Set qRows = ds.execute(query)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Execute Query
qrows.movefirst&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Read results
countRec = qRows.fields(1).value
flds("LITHORDERNUMBER").value = countRec + 1
End Sub&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:47:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcpad-questions/sum-column-in-related-table-and-populate-editform/m-p/260240#M1896</guid>
      <dc:creator>JasonTipton</dc:creator>
      <dc:date>2021-12-11T12:47:59Z</dc:date>
    </item>
  </channel>
</rss>

