<?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: Automated unique sequential ID field. in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396285#M10575</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Maya, here's a good place to start, it took me a little while to remember where I found this.&amp;nbsp; The State of Utah put this nice little VBA script together.&amp;nbsp; It doesn't generate a unique id, but it does use an Editor event listener that responds to an On Create Feature event.&amp;nbsp; You'd need to modify the script to generate a unique id rather than applying a time stamp.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://gis.utah.gov/code-visual-basic/vba-edit-timestamp-script-2"&gt;http://gis.utah.gov/code-visual-basic/vba-edit-timestamp-script-2&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I talked to someone at the users conference last year who had a different solution.&amp;nbsp; He created Python script and scheduled it to run every night.&amp;nbsp; The script first found the Max ID and then all the features with a null ID.&amp;nbsp; It then populated the null IDs incrementing from the Max ID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good Luck!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Mar 2011 20:11:20 GMT</pubDate>
    <dc:creator>BrettHill</dc:creator>
    <dc:date>2011-03-03T20:11:20Z</dc:date>
    <item>
      <title>Automated unique sequential ID field.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396284#M10574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I posted this in another ArcGIS forum (&lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/24626-Automated-unique-sequential-ID-field.?p=81810&amp;amp;posted=1#post81810"&gt;link&lt;/A&gt;&lt;SPAN&gt;), and it was suggested to post it here as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]This may be a bit of a newbie question but I was hoping someone could help me. I need to create a unique sequential id field ("ID_NUMBER") that is not a GlobalID or based on the Object ID field and whose range is fixed (say from 200,000 to 400,000). It is for a feature class of approx 1000 records. I have managed to use the field calculator to populate the "ID_NUMBER" field for existing records, but what I would like to do now is to automate this process so that when a new feature is drawn/created the "ID_NUMBER" field is automatically populated with the next available ID number within the specified range.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to do this using existing ArcGIS functionality/settings, such as through subtypes or domains? Or will this need to be programmatically implemented? I've had a brief look through the previous forums but couldn't find anything to point me in the right direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working with ArcGIS Desktop 9.3.1 and have access to an ArcInfo licence.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any advice much appreciated![/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maya&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 03:56:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396284#M10574</guid>
      <dc:creator>MayaDominice</dc:creator>
      <dc:date>2011-03-02T03:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Automated unique sequential ID field.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396285#M10575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Maya, here's a good place to start, it took me a little while to remember where I found this.&amp;nbsp; The State of Utah put this nice little VBA script together.&amp;nbsp; It doesn't generate a unique id, but it does use an Editor event listener that responds to an On Create Feature event.&amp;nbsp; You'd need to modify the script to generate a unique id rather than applying a time stamp.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://gis.utah.gov/code-visual-basic/vba-edit-timestamp-script-2"&gt;http://gis.utah.gov/code-visual-basic/vba-edit-timestamp-script-2&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I talked to someone at the users conference last year who had a different solution.&amp;nbsp; He created Python script and scheduled it to run every night.&amp;nbsp; The script first found the Max ID and then all the features with a null ID.&amp;nbsp; It then populated the null IDs incrementing from the Max ID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good Luck!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 20:11:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396285#M10575</guid>
      <dc:creator>BrettHill</dc:creator>
      <dc:date>2011-03-03T20:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Automated unique sequential ID field.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396286#M10576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are likely looking at some kind of customization in ArcGIS for what you want to do.&amp;nbsp; If you are using an enterprise DBMS (Oracle/SQL server) then you might want to look into setting up triggers on the DB level as an alternative.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 23:23:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396286#M10576</guid>
      <dc:creator>SteveFang</dc:creator>
      <dc:date>2011-03-03T23:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Automated unique sequential ID field.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396287#M10577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the pointers - much appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At this stage the data is being maintained and updated in a single file geodatabase, but it is envisioned for it to eventually migrate to a DBMS environment, which I imagine is definitely something to keep in mind when setting up fields. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will have a look at both options (the VBA code and Python script idea) and see which suit the situation the best (perhaps even a combination of the two?). From what I can remember offhand its possible to call a Python script from within VBA code, though I could be wrong. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My VBA and Python skills are at a somewhat beginner-intermediate level at this stage, so I will give it a go and see what comes out of it. I'll post back with any code/problems, in case other people are having similar troubles/questions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maya.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 05:47:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396287#M10577</guid>
      <dc:creator>MayaDominice</dc:creator>
      <dc:date>2011-03-04T05:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Automated unique sequential ID field.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396288#M10578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've managed to figure out a (if anything, temporary) solution. This is the code I've written, as adapted from the script provided on the State of Utah website (by Bert Granberg). It seems to work, though I haven't had much of a chance to test it thoroughly. I'm also going to add in an error handler to check for duplicate/non-unique/Null values as well as non-numeric/'user-accidentally-entered/altered' values. But this is the code as it stands at the moment. Thanks again for the pointers! If anyone has any further advice/comments, post away; otherwise, consider this query answered &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'===========================================================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'Title: Automate ID_NUMBER field population&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'Purpose: To automatically populate the above mentioned field with a unique sequential ID number.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'Date: 14/03/2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'Author: Maya Dominice&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'References:The code was adapted from Bert Granberg's "VBA Edit &amp;amp; Timestamp Script", available at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://gis.utah.gov/code-visual-basic/vba-edit-timestamp-script-2" rel="nofollow" target="_blank"&gt;http://gis.utah.gov/code-visual-basic/vba-edit-timestamp-script-2&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'===========================================================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'===========================================================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Option Explicit&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Private m_bPopulate As Boolean&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Private m_EditEventChange As Boolean&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Private WithEvents m_pEditEvents As Editor&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Private Function MxDocument_OpenDocument() As Boolean&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pEditor As IEditor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pUID As New UID&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pUID = "esriCore.Editor"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pEditor = Application.FindExtensionByCLSID(pUID)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If pEditor Is Nothing Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "Unable to Enable UIC Custom Editing Environment", vbOKOnly, "ERROR...UIC Editing Environment"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Function&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set m_pEditEvents = pEditor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_bPopulate = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_EditEventChange = False&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "Edit Event Field Population is Enabled", vbOKOnly, "AGRC Custom Editing..."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;End Function&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Private Sub m_pEditEvents_OnCreateFeature(ByVal obj As esriGeoDatabase.IObject)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'Creates new ID number for new feature&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim pRow As IRow&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim newIDIndex As Integer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim pTable As ITable&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim pCursor As ICursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim pData As IDataStatistics&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim pStatResults As IStatisticsResults&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim IDMax As Variant&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim NewID As Long&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Dim changeMade As Boolean&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Set pRow = obj&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; If Not m_bPopulate Then Exit Sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; 'Find index (as long) of "ID_NUMBER" field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; newIDIndex = pRow.Fields.FindField("ID_NUMBER")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; 'Set up cursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Set pTable = obj.Table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Set pCursor = pTable.Search(Nothing, False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; 'Set up statistics parameters&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Set pData = New DataStatistics&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; pData.Field = "ID_NUMBER"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Set pData.Cursor = pCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; 'Find the max value of the "ID_NUMBER" field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Set pStatResults = pData.Statistics&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; IDMax = pStatResults.Maximum&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; 'Add 1 to create next (sequential)ID number&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; NewID = IDMax + 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; changeMade = False&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; If newIDIndex &amp;gt; 0 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pRow.Value(newIDIndex) = NewID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; changeMade = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; If changeMade Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_EditEventChange = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pRow.Store&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; m_EditEventChange = False&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>Mon, 14 Mar 2011 06:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/automated-unique-sequential-id-field/m-p/396288#M10578</guid>
      <dc:creator>MayaDominice</dc:creator>
      <dc:date>2011-03-14T06:54:42Z</dc:date>
    </item>
  </channel>
</rss>

