Select to view content in your preferred language

auto increment ID in arcpad

3899
2
05-17-2010 09:11 AM
JeffGodfrey
Emerging Contributor
I am trying to setup and auto incrementing ID in an ArcPad form.  I want the ID number to be automatically created upon the creation of the point in arcpad.  I would also like the ID number to have a certain format.  The first part of the ID would consist of a static text of "U12010" and then grab the FID field and add 100 to it.  An example is, 1U2010102.
I can easily do this in ArcMap, but I am having trouble figuring out how to do this in ArcPad.
Do I need to write VB code a the control properties(onsetfocus) of the field in editform portion of the .apl?
I am using ArcPad 8

Thank you
Jeff Godfrey
jeff.godfrey@co.chelan.wa.us
Tags (3)
0 Kudos
2 Replies
DaveAlmond
Regular Contributor
Jeff-
  Short answer- Yes, you need to write a script to do this in ArcPad.  You may want to create the unique ID by calling your autoincrement script from the 'On FeatureAdded' event for the layer, and then pass that value to an initialization script the form'OnLoad' event to initialize the form control as it is loading.  That said, we had so much trouble getting an autoincrement script to work in ArcPad (no programmers here) that we decided to use a Julian Date (yymmdd + 24:00 hour time) as our unique ID field, which is easily done by accessing the date/time object.
0 Kudos
GarethWalters
Deactivated User
Hi Jeff,

You could try something like this:



Sub CreateUID()

Dim intRand, myDate, myTime
intRand = round(rnd*1000000)

If Map.EditLayer.Forms("Editform").Pages("Page1").Controls("txtUID").Value = "" Then
Map.EditLayer.Forms("Editform").Pages("Page1").Controls("txtUID").Value = intRand & "_" & Date()
End If

End Sub

You could then set this to the Page OnSetActive event or the Forms OnLoad event.

Obviously you replace the random section with your standard prefix.

Hope this helps.

Cheers,

Gareth
0 Kudos