I'm trying to create a Unique ID that pops up on a custom form I'm making in ArcPAD. This is needed so field workers can include this number on some supplemental paper tables that they carry around.

I've pasted together the following code which mostly works; however, if someone uses the repeat attributes toggle then the "unique" ID is also repeated.

Is there any way to test to see if the repeat attributes toggle is on or off?

I can't find it anywhere in the Object Model.

Here's my code. This runs on the ONLOAD event for the form (sorry for the lack of documentation). This basically just loops through the features and finds the highest number in the ID field and adds 1. If the ID box on the form is already populated this is not executed.

Option Explicit
Dim varUniqueID

Sub UniqueID2
    Dim objRS, HighValue, CurrentValue, objEFPageOneControls, objEditForm 
    Set objRS = Application.map.layers("OFF_ROAD").records
    Set objEditForm = application.map.layers("OFF_ROAD").forms("EDITFORM")
    Set objEFPageOneControls = objEditForm.Pages("Page1").Controls

    If (objEFPageOneControls("IDBOX").Value = "") Then
        If (objRS.RecordCount > 0) Then

            HighValue = objRS.Fields("ID").Value

            While Not objRS.EOF
                CurrentValue = objRS.Fields("ID").Value

                if HighValue < CurrentValue Then
                    HighValue = CurrentValue
                End If

            HighValue = HighValue + 1
        End If
        objEFPageOneControls("IDBOX").Value = HighValue     
    End If
End Sub

1 Answer 1


If you check out the Tree Register template that comes with ArcPad, open the .js file in ArcPad Studio and in there you will that I wrote a couple of checks to over come this.

You need to check to see if it is a new record as opposed to editing an existing feature. Also check that you don't change the ID mid way through editing by changing pages - because I put this on the page OnSetActive event.

N.B. It is not a hard and fast rule but I try to remove what I can from the form Onload event, only because elements might not be available to me until the actual pages are loaded.

So when I create a feature I run SetUID() and this just stores some values for me to test against when a new feature is created.

Let me know how you get on.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.